| Welcome to WebmasterWorld Guest from 18.104.22.168 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe and Support WebmasterWorld|
|preg replace help needed|
| 9:24 pm on Dec 2, 2008 (gmt 0)|
I'm trying to remove all bbcode tags in my forum post with the following:
$patterns = "/\[.+\]/i";
$replacements = "";
$postText = preg_replace($patterns, $replacements, $postText);
However when running into the following it will match the entire string below (and thereby remove it):
Instead it should have matched tag1 then tag2 then... and so on.
Any input on what I can do to accomplish this without trying to match each individual tag?
Thanks in advance.
| 7:44 am on Dec 3, 2008 (gmt 0)|
it seems i need to change the pattern from greedy to ungreedy by using the ? quantifier or /U.
| 8:25 am on Dec 3, 2008 (gmt 0)|
Yes, you're right - add ? after the +
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2013 all rights reserved