Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: This regexp made simpler

by FunkyMonk (Chancellor)
on Apr 25, 2010 at 11:31 UTC ( [id://836771]=note: print w/replies, xml ) Need Help??


in reply to Re^2: This regexp made simpler
in thread This regexp made simpler

Updating my post to accommodate the anchors and your update:
my @strings = ('AZ', 'A SOMETHING Z', 'ASOMETHINGZ', 'A Z', 'A ZZ', ' +AA ZZ', 'AAZZ', 'A Z'); for (@strings) { if (/^A( [^Z]*)?Z$/) { my $grabbed = $1 // ''; say "'$_' grabbed '$grabbed'"; } else { say "'$_' did not match" } } __END__ 'AZ' grabbed '' 'A SOMETHING Z' grabbed ' SOMETHING ' 'ASOMETHINGZ' did not match 'A Z' grabbed ' ' 'A ZZ' did not match 'AA ZZ' did not match 'AAZZ' did not match 'A Z' grabbed ' '


Unless I state otherwise, all my code runs with strict and warnings

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://836771]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found