Jump to content

Archived

This topic is now archived and is closed to further replies.

fareforce

php preg_match problem

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!  =)

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.