rsiedl has asked for the wisdom of the Perl Monks concerning the following question:
Cheers,#!/usr/bin/perl use strict; use warnings; my @bah = ( "Australia", "Austria", "Finland", "Norway" ); my $foo = "In Australia the people from Austria drink beer at the pub +with the people from Norway"; my $result = ""; foreach my $match (@bah) { if ($foo =~ /\Q$match\E/ig) { $result .= $match . " "; } # end-if } # end-foreach print $result, "\n"; exit; # Result = Australia Austria Norway
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex matching using arrays
by zejames (Hermit) on Dec 04, 2004 at 10:58 UTC | |
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 | |
Re: regex matching using arrays
by TedPride (Priest) on Dec 05, 2004 at 03:30 UTC |