BBCode using Preg_Replace
View Single Post
04-07-2008, 01:57 PM
Join Date: Dec 2007
Originally Posted by
Broken down, it means:
. matches any character except a newline
* matches whatever precedes it (in this case the ".") 0 or more times.
? matches as few times as possible.
So .* acts a lot like a wildcard when you need to match a variety of possible strings, however, it's greedy, so if you're trying to match
in a string that contains
(b)something(/b) and (b)something else(/b) followed by (b)this(/b)
because it's greedy, it will match from the first (b) all the way down to the last (/b). Make it lazy, and .* only matches as little as possible till it finds something that'll complete the pattern, such as the first (/b) instead of the last one.
For the sake of this post, pretend that all ('s and )'s are ['s and ]'s, because I'm apparently too retarded to figure out how to display them without having them parsed.
Hey, if you're trying to replace a whole string, and want one piece of the string to still be in tact, how do you do that?
VillageIdiot can have my babbies ;d
View Public Profile
Send a private message to Orc
Visit Orc's homepage!
Find More Posts by Orc