in reply to Re: Sparing multiple 'or's
in thread Sparing multiple 'or's
Note that the results for the examples of the two methods differ:
See haukex's Building Regex Alternations Dynamically.c:\@Work\Perl\monks>perl -wMstrict -le "my @cases = qw/ABA SCO ACC PHC GHF/; my $re = join '|', @cases; ;; for my $text ('SCO', 'ENDOSCOPE', 'Microsoft') { print qq{'$text' found (grep)} if grep { $text eq $_ } @cases; print qq{'$text' found (regex)} if $text =~ /^$re$/; } " 'SCO' found (grep) 'SCO' found (regex) 'ENDOSCOPE' found (regex)
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sparing multiple 'or's
by hippo (Archbishop) on Jun 04, 2018 at 21:02 UTC |