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 :)