preg issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

preg issue

Post by m3rajk »

i have a quote set up i made that replaces the blockquote of html that's been deprecated. issue is that the preg replacement doesn't work on nested quotes. not quite sure why. if anyone can tell me why and help me fix it, i would appreciate that.current php preg search:[php # add quotes
$postcode=preg_replace('|\[/quote]|i', '<hr /></div>', $postcode);
$postcode=preg_replace('|\[quote(=(.*))(?U)]|i', '<div class="quote">Quote \2<hr />', $postcode);result can bee seen in this thread:http://www.findyourdesire.com/forums.php?fid=4&tid=13 (currently the last post has got a nested one)

thanx in advance for the help

ps- an aside. i have something else i'm doing and using sessions there. just as question since i'm not used to sessions, is my understanding that any session variable that gets registered i can access via $variable instead of $_SESSION['variable']?
dodga
Forum Newbie
Posts: 9
Joined: Sat Feb 07, 2004 2:10 pm
Location: Benztown, Germany

Post by dodga »

I think the problem is that RegEx tend to find the longest possible match.
Have a look at this page - which actually is for sed, but it uses the same RegEx :D
:arrow: http://www-106.ibm.com/developerworks/l ... -sed2.html

Look out for the "Regexp snafus"; should be pretty much the same situation as yours :wink:
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

hmmm... volka i think isthe one who gave me the ?U trick for non-greedy. i don't see anything that helps fix it :(
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

figured it out. just have ot changehow the non-greedy is signaled
Post Reply