04-07-2008, 01:57 PM
|
#24 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by delayedinsanity
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.
|
Thanks!
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
|
|
|
|