in reply to Re: Monks' Expression
in thread Monks' Expression
Interesting. As has been mentioned before, .* here is bad because it's greedy and will prevent you from finding two matches on a line. Furthermore, .* is usually pretty inefficient -- the regexp has to match everything to the end of the line and then start backtracking to try to match whatever follows the .*. (.*? is better but still less than ideal to because it needs to look ahead one character in every step. If '[' is only allowed in tags, then [^[]* is the best.)
Also, why use $before and $after rather than $` and $' directly? Of course, if at all possible, you shouldn't be using $` and $' at all (see Why does using $&, $`, or $' slow my program down? in perlfaq6).
Cheers, mate!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Monks' Expression
by Segfault (Scribe) on Jan 22, 2001 at 23:51 UTC |