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.
In reply to Re^3: regex matching specific strings.
by markkawika
in thread regex matching specific strings.
by nafion112
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |