in reply to Re^2: returning matched word from string
in thread returning matched word from string
# Any word matched while (<$words_fh>) { my $re = join '|', map quotemeta, split; if ( $teststring =~ /($re)/ ) { print("$teststring contains $1\n"); } }
# Each word matched while (<$words_fh>) { for my $word ( split ) { if ( $teststring =~ /\Q$word/ ) { print("$teststring contains $word\n"); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: returning matched word from string
by monaghan (Novice) on Jul 23, 2008 at 18:38 UTC |