| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|preg replace help needed|
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.
it seems i need to change the pattern from greedy to ungreedy by using the ? quantifier or /U.
Yes, you're right - add ? after the +
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved