kidd has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks...
Yesterday you helped me with some problem and I was able to solve it, thanks.
Now I have a question:
Is there a way to check if a line has a word of an array(that has a different number of words) using regexp?...
Some example:
My goal is to check trough the @query ans see if any word is in $line. Considering that I will not know the values in @query.my @query = ('red', 'blue', 'white'); my $line = "That is a blue wall";
At the moment Im using a foreach() loop, that Im hoping to kill with a one liner:
foreach my $query(@query){ next if $query eq ''; print "I found: $query" if $line =~ /\Q$query/; }
Thanks...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regexp question
by Abigail-II (Bishop) on Aug 19, 2002 at 16:01 UTC | |
by kidd (Curate) on Aug 19, 2002 at 16:08 UTC | |
by Abigail-II (Bishop) on Aug 19, 2002 at 16:13 UTC | |
by kidd (Curate) on Aug 19, 2002 at 16:39 UTC |
Back to
Seekers of Perl Wisdom