fareforce Posted September 19, 2006 Share Posted September 19, 2006 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 More sharing options...
btherl Posted September 19, 2006 Share Posted September 19, 2006 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 More sharing options...
fareforce Posted September 19, 2006 Author Share Posted September 19, 2006 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 More sharing options...
effigy Posted September 20, 2006 Share Posted September 20, 2006 Works OK for me. Check your input. Link to comment https://forums.phpfreaks.com/topic/21234-php-preg_match-problem/#findComment-95029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.