View Single Post
Old 04-07-2008, 01:54 PM   #23 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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.
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
Orc (04-07-2008)