in reply to regex for case insensitive

If you're looking for in-line control of case insensitivity, use  (?i) to turn it on;  (?-i) turns it off. See  (?imsx-imsx) in Extended Patterns in perlre.

c:\@Work\Perl\monks>perl -wMstrict -le "my @needles = ('1-2 Steps', '5-7 Steps', '8-10 Steps', 'cAtCh', '*+ +??er',); my @haystacks = ( 'move 1-2 steps', 'move 8-10 steps to hoist', 'catch the ball', 'du +mb *+??ER', ); ;; for my $needle (@needles) { my $found; for my $haystack (@haystacks) { if ($haystack =~ /(?i)\Q$needle\E/) { print qq{Found [$needle] in [$haystack]}; ++$found; } } ;; if (!$found) { print qq{Could not find [$needle] anywhere!}; } } " Found [1-2 Steps] in [move 1-2 steps] Could not find [5-7 Steps] anywhere! Found [8-10 Steps] in [move 8-10 steps to hoist] Found [cAtCh] in [catch the ball] Found [*+??er] in [dumb *+??ER]


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.