in reply to Re: More than one regexp.
in thread More than one regexp.
The problem with this is that you have to compile a new regular expression for every line of $input. You can do this sort of alternation in a regular expression like
my @patterns = qw/ test good /; my $alt = join('|', @patterns); my $re = qr/(?:$alt)/; while (<DATA>) { if ( /$re/ ) { print "+ $_"; } else { print "- $_"; } } __END__ THis is a test this is only a test now is the time for all good men to come to the aid of their country.
Other than perlop and perlre, a good place to look for regular expressions is the Jeffery Friedl book, Mastering Regular Expressions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: More than one regexp.
by dws (Chancellor) on Jan 19, 2001 at 22:15 UTC |