Welcome to Rocteur Thursday, March 28 2024 @ 09:55 PM CET
How do I create a regular expression search with modifier on the fly ?This is why '(?i)' was invented. You want something like this: my $word = 'word'; my $modifier = '(?i)'; my $string = 'a string that has Words in it'; if ($string =~ /$modifier$word/) { print "match!\n"; } Hope this helps! --Tom Phoenix Stonehenge Perl Training
$word = 'word'; $modifier = 'i';
if ( $string =~ /(?$modifier:$word)/ ){ print "match\n"; }
John -- John W. Krahn
FAQ Manager » Perl » How do I create a regular expression search with modifier on the fly ?
|