in reply to Re: Matching multiple patterns with regex
in thread Matching multiple patterns with regex
my @fields = qw/From: Subject:/; # you can add more if/when you want my $field_regex = join( "|", @fields );
I would change the second line to use quotemeta:
my @fields = qw/From: Subject:/; # you can add more if/when you want my $field_regex = join( "|", map { quotemeta($_) } @fields );
It may be unneeded for From: and Subject:, but code may change over time, and adding quotemeta now prevents future bugs.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Matching multiple patterns with regex
by graff (Chancellor) on Oct 31, 2015 at 15:38 UTC |