BenjiSmith has asked for the wisdom of the Perl Monks concerning the following question:
my @blacklist = ('evil', 'bad', 'wrong'); my $a = "this string contains no blacklisted tokens"; my $b = "this string is evil and wrong"; # The regex should express the blacklist is such a way that # it will match on any string which DOES NOT contain any of # the tokens in the blacklist, and it will fail to match on # any string which DOES contain tokens from the blacklist. my $regex = '?????'; if (($a =~ m/$regex/) && !($b =~ m/$regex/)) { # SUCCESS }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Blacklisting with a Regular Expression
by Eimi Metamorphoumai (Deacon) on Aug 18, 2005 at 22:50 UTC | |
by BenjiSmith (Novice) on Aug 18, 2005 at 23:26 UTC | |
by hv (Prior) on Aug 19, 2005 at 01:29 UTC | |
|
Re: Blacklisting with a Regular Expression
by AReed (Pilgrim) on Aug 18, 2005 at 22:03 UTC | |
|
Re: Blacklisting with a Regular Expression
by davidrw (Prior) on Aug 18, 2005 at 22:05 UTC | |
|
Re: Blacklisting with a Regular Expression
by Nkuvu (Priest) on Aug 18, 2005 at 22:01 UTC | |
|
Re: Blacklisting with a Regular Expression
by greenFox (Vicar) on Aug 19, 2005 at 06:12 UTC | |
by jonnyfolk (Vicar) on Aug 19, 2005 at 11:56 UTC |