in reply to regex matching specific strings.
$var =~ /^(?:(?:abc)|(?:def)|(?:ghi))$/;
Regarding skipping regular expressions entirely, since you are testing literal equality, it may make more sense from a maintenance perspective to just test equality with a set of or clauses (perlop):
if ($var eq 'abc' or $var eq 'def' or $var eq 'ghi') { ..code..}
Update: Fixed code, as per ikegami's post below
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex matching specific strings.
by ikegami (Patriarch) on Jul 22, 2009 at 23:07 UTC | |
by markkawika (Monk) on Jul 22, 2009 at 23:50 UTC | |
by Anonymous Monk on Jul 23, 2009 at 00:42 UTC |