in reply to Re: Regex Question
in thread Regex Question

Close.
if (grep { $pass =~ /$_/ } map quotemeta, @badwords) {
or
if (grep { index($pass, $_) >= 0 } @badwords) {
or
my $re = join '|', map quotemeta, @badwords;
if ($pass =~ /$re/) {

Replies are listed 'Best First'.
Re^3: Regex Question
by Ieronim (Friar) on Jul 12, 2006 at 23:17 UTC
    Less scalable, as you cannot add regexes to @badwords ;)
      @badwords can't contain both regexps and words. For example, your solution will fail with words (e.g. f*ck won't work), mine will fail with regexps (e.g. f[u*]ck won't work). I assumed you wanted words since your called your array @badwords.

      Both solutions are fine (although the name @badwords is a bit misleading if it contains regexps) depending on what is needed.