Next | Regular Expression Mastery | 26 |
Consider "Hot XXX Action!" =~ s/X*//
/X*/
It gets the empty string, not XXX
Even though XXX is longer
Because Perl starts at the leftmost position first
X* will match zero Xes.
At the leftmost position, there are zero Xes.
Solution: Use X+ instead
Maxim: ``Say what you mean!''
People over-use *
Many *'s should be + instead
Next | Copyright © 2002 M. J. Dominus |