NAME
Regexp::Any - Match many regexes against a variable
SYNOPSIS
use Regexp::Any;
my @array = qw(Foo Bar Wibble);
my $opt = 'i'; #ignore case
my $var = "foo";
if($var =~ match_any(\@array,$opt)){
print "It matched\n";
}else{
print "It didn't match\n";
}
sub profane {
my $word = shift or die 'must supply word to match';
my $re = match_any_and_capture(\@profanity, $re_opt);
if ($word =~ /($re)/) {
return (1, $1);
} else {
return (0);
}
}
DESCRIPTION
This module allows you to pass the match_any() function a reference to an array of regexes which will then return a full regex for the the variable to be matched against. Optionally, you can pass it matching arguements such as 'g' or 'i'. Pass these in one variable with no spaces. Note: I from personal experience have found this module to be very handy for use with Mail::Audit.
An second function match_any_and_capture
, will supply capturing parentheses to the generated regular expression, which can prove useful if you want to know which part of your regexp matched.
AUTHOR
Terrence Brannon <tbone@cpan.org> supplied C<match_any_and_capture>
Scott McWhirter <scott@kungfuftr.com> wrote Regexp::Match::Any but
did not uploaded the patches to it which I needed for my module
Regexp::US::Profanity to piggyback on his module.
So I was forced to release similar functionality under a different name;