What if the user entered m/foo/x when asked for a regex? Technically, the regex the user wanted was foo, but they entered the whole match command instead:
Obviously, m/MI-6/x (they want to match "MI-6", not "m/MI-6/x"). How could that be corrected for?my $keywords = "NSA|cocaine|Lybia|assasin(at(ion|e))?|CIA"; print "Enter regex matching other keywords:"; my $userwords = <STDIN>; # user enters "m/MI-6/x" if ($string =~ m/$keywords|$userwords/x) { print "Found a terrorist! $string\n"; }
In reply to RE: Re: Converting RegExs.
by BlaisePascal
in thread Converting RegExs.
by dcorbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |