BBCode using Preg_Replace
View Single Post
04-07-2008, 01:54 PM
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
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.
The Following User Says Thank You to delayedinsanity For This Useful Post:
View Public Profile
Send a private message to delayedinsanity
Visit delayedinsanity's homepage!
Find More Posts by delayedinsanity