P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Pay attention to the exact wording. * is a quantifier, it says "match ZERO OR MORE". There's no particular character it matches, it's just that any string you care to pass it satisfies the condition "has zero or more 'a's in it". By itself, /a*/ isn't a very useful regular expression (nor, for that matter, is /a+?/ as opposed to simply /a/, because that will match a single 'a' and no more (the shortest string of one or more "a"s is one "a"). Try it :perl -e 'print "Yee haw!\n" if "bob" =~ /a*/' Better yet, perl -e 'print "Yee haw!\n" if undef =~ /a*/' HTH!
In reply to Re: Re: Re: Question on REGEX
by arturo
|
|