in reply to Yet another regex question
Don't use character class, use alternations and anchoring in case the string is longer than one character: =~ m/^(?:7|8|9)$/. Don't forget to use quotemeta on the strings.
sub dequote { local $_ = (@_ ? $_[0] : $_); s/^'//; s/'$//; s/\\(.)/$1/s; return $_; } my $list = join '|', map quotemeta, map dequote, @parts; print("=~ m/^(?:$list)\$/");
How do you extract the parts? Well, that's quite hard to do right using regexp. You should write a parser.
|
|---|