yes, i think you definitely see if anything matches, and then negate that. So if it matches /evil|bad|wrong/ then it is a bad string that should be blacklisted. Now, that regex can be formed dynamically:
my $good = "this string contains no blacklisted tokens"; my $bad = "this string is evil and wrong"; my @blacklist = ('evil', 'bad', 'wrong'); my $re = join '|', @blacklist; warn 'good string is ok' if $good !~ /\b(?:$re)\b/i; warn 'bad string failed' if $bad =~ /\b(?:$re)\b/i;
Note that i took the liberty of using the /i modifier, and also added the word boundries. Also note that ?: is just so it doesn't needlessly capture.
Note also that look-aheads aren't needed here unless you care for some reason about the order of the blacklist hits, but it seems like you only care if they exist at all..

In reply to Re: Blacklisting with a Regular Expression by davidrw
in thread Blacklisting with a Regular Expression by BenjiSmith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.