Jorge Almeida:
> Please help me to understand this:
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> $ echo $?
> $ 10
In man perlre, under "Regular Expressions" it says:
{,n} Match at most n times
So /a{,2}/ matches "", "a", and "aa" and is ignorant about what
comes before and after (basically). That "aa" is followed by a
"a" isn't something the expression prohibits. If you want that
try /^a{,2}$/ instead.
Regards,
/Karl Hammar
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/