in reply to Re: Converting RegExs.
in thread Converting RegExs.
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: Converting RegExs.
by merlyn (Sage) on Sep 04, 2000 at 17:53 UTC | |
by davorg (Chancellor) on Sep 04, 2000 at 18:31 UTC | |
by tilly (Archbishop) on Sep 04, 2000 at 18:40 UTC | |
by dcorbin (Sexton) on Sep 05, 2000 at 16:59 UTC |