RegEx problems ([quote] tags)

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

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nonononon.. I used the matches found in the preg_match call to do the str replace.. not str_replacing the beginning and ending junk..
tony montana
Forum Newbie
Posts: 21
Joined: Tue Sep 28, 2004 11:10 am

Post by tony montana »

I have no idea how todo that :x
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a preg_match* returns the string it matched, plus any groupings you requested.. Since the preg_match_all I wrote returns the offsets, you can use those to extract the entire string (from beginning to its actual end) to replace. Once you have this entire string, you can use a preg_replace on it to change out the beginning and ending marks (using the greedy syntax)
tony montana
Forum Newbie
Posts: 21
Joined: Tue Sep 28, 2004 11:10 am

Post by tony montana »

lol I got lost, besides thats pretty extreme for something like quote tags.

Any other ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I haven't ever had any problems with using preg_replace with the quote tags before..
tony montana
Forum Newbie
Posts: 21
Joined: Tue Sep 28, 2004 11:10 am

Post by tony montana »

Big diffrence between preg replace and what your proposing ;p
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there's actually not all that much different.. the way I first suggested handles things that can be sensitive to nesting.
Post Reply