Jump to content

Recommended Posts

I am having problems with a preg_match. The bit of code I need to match up is:
[code]document.images['picture'].src = "images/" + Views[View] + "3.png";[/code]

The code I tried is, but it didn't work:
[code]preg_match("|src = \"images/\" + Views[View] + \"(.*).png\"|Uis",get_put($url_aurora),$aurora);[/code]

I am not very good with php code so I am sure I messed something up. Can anyone help me? Another line of code I could pull this from would be:
[code]document.write ('3.png" border="0">');[/code]


Any help would be greatly appriciated!  =)
Link to comment
https://forums.phpfreaks.com/topic/21234-php-preg_match-problem/
Share on other sites

There's a specific forum for regex questions..

I think your problem here is that "+" is a metacharacter.  You need to use \+ if you want to match an actual + sign.  "[" and "]" also need to be escaped, as \[ and \].  The rest looks ok to me
Link to comment
https://forums.phpfreaks.com/topic/21234-php-preg_match-problem/#findComment-94489
Share on other sites

Ok. I tried using:
[code]preg_match("|src = \"images/\" \+ Views\[View\] \+ \"(.*)\.png\"|Uis",get_put($url_aurora),$aurora);[/code]
but it still isn't working.

I guess I should also add the 3 (in the above example) is the variable I am pulling. It can range from 0-10.
Link to comment
https://forums.phpfreaks.com/topic/21234-php-preg_match-problem/#findComment-94903
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.