in reply to Re: Tracking consecutive characters
in thread Tracking consecutive characters
Careful there: only the second number is optional. If you miss out the first number perl will fail to recognise the braces as a quantifier, and so it gets treated as a literal string to match instead:
zen% perl -wle 'print "miss" if "aa" !~ /^a{,3}$/' miss zen% perl -wle 'print "match" if "aa" =~ /^a{0,3}$/' match zen% perl -wle 'print "match" if "a{,3}" =~ /^a{,3}$/' match zen%
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tracking consecutive characters
by Aristotle (Chancellor) on Sep 27, 2004 at 13:36 UTC |