04-07-2008, 01:54 PM
|
#23 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
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
(b)text(/b)
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.
|
|
|
|