craziest
asked on
Ignoring AND in perl
i want to search for two words and inbetween them i use AND
whats the code for ignoring AND?
any help would be appriciated,thanx
whats the code for ignoring AND?
any help would be appriciated,thanx
How are you searching for two words and using AND?
What do you want to do when you ignore AND?
What do you want to do when you ignore AND?
I'll interpret the question as having
word1 AND word2
and wanting to match them and "ignoring" the AND.
$string='word1 AND word2';
if ($string ~= /word1\s+\w+\s+word2/i) {
print "Matched\n";
}
The above matches word1 followed by one or more whitespace, one or more word characters and one or more whitespace followed by word2. The match is case insensitive.
There's loads of other combinations, but you need to be much more specific with your requirements.
word1 AND word2
and wanting to match them and "ignoring" the AND.
$string='word1 AND word2';
if ($string ~= /word1\s+\w+\s+word2/i) {
print "Matched\n";
}
The above matches word1 followed by one or more whitespace, one or more word characters and one or more whitespace followed by word2. The match is case insensitive.
There's loads of other combinations, but you need to be much more specific with your requirements.
ASKER
https://www.experts-exchange.com/questions/22048966/Perl-Double-quote-problem.html
thats my code,thnx to ozo i managed to get the double quotes.now i mean if someone types AND inbetween two words it should look for both the words.Tintin is almost there but i didnt know how it would be on my code.thanks.
thats my code,thnx to ozo i managed to get the double quotes.now i mean if someone types AND inbetween two words it should look for both the words.Tintin is almost there but i didnt know how it would be on my code.thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You just say
if ( str =~ /word1 AND word2/ )
{
print "Found word1 word2\n";
}