Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: regex matching specific strings.

by markkawika (Monk)
on Jul 22, 2009 at 23:50 UTC ( [id://782497]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex matching specific strings.
in thread regex matching specific strings.

My only tiny quibble with that regex, correct as it is, is that using ^ in combination with \z might be confusing to a future reader. I'd suggest:

$var =~ /\A(?:abc|def|ghi)\z/;

Which is technically exactly the same as ikegami's suggestion, but points out to the reader "Hey I'm using less-common techniques in this regex" right at the beginning with that \A.

Replies are listed 'Best First'.
Re^4: regex matching specific strings.
by Anonymous Monk on Jul 23, 2009 at 00:42 UTC
    That is funny, because every single character in a regex could be critical, so unless you know exact meaning of every single character, you should be very very careful :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-09-17 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (22 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.