The lack of follow-up questions from salp suggests he or she has the "store the regex in a hash" part under control, but just in case:
>perl -wMstrict -le "my %rx = ( FOO => qr{ (?i) foo (?! bar) }xms, BAR => qr{ (?i) bar (?= (?-i) foo) }xms, ); ;; my $s = 'xxx FooBar fOO BaRFoO bArfoo bar yyy'; for my $type (keys %rx) { print qq{parsing $type-ish stuff with $rx{$type}}; while ($s =~ m{ ($rx{$type}) }xmsg) { print qq{ found a '$1'}; } } " parsing BAR-ish stuff with (?msx-i: (?i) bar (?= (?-i) foo) ) found a 'bAr' parsing FOO-ish stuff with (?msx-i: (?i) foo (?! bar) ) found a 'fOO' found a 'FoO' found a 'foo'
In reply to Re: store regex in hash
by AnomalousMonk
in thread store regex in hash
by salp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |