in reply to regex matching using arrays
Yes you can, by using logical OR in regex
use strict; use warnings; my @bah = ( "Australia", "Austria", "Finland", "Norway" ); my $regex = join ('|', map { "(?:$_)" } @bah); my $foo = "In Australia the people from Austria drink beer at the pub +with the people from Norway"; my $result = ""; my @data = $foo =~ /($regex)/g; print join ", ", @data;
HTH
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regex matching using arrays
by rsiedl (Friar) on Dec 04, 2004 at 11:08 UTC | |
by BUU (Prior) on Dec 04, 2004 at 11:34 UTC | |
by ikegami (Patriarch) on Dec 05, 2004 at 17:34 UTC | |
by graff (Chancellor) on Dec 08, 2004 at 03:52 UTC |