Sent: Tuesday, March 18, 2003 1:13 PM
Subject: searching a string
Hi
i am searching for a string of consecutive words say "the lucky
coin"
These may be in one line or different line separated by blank
lines such as
1>the
lucky coin
2>thelucky
c
Note: Forwarded message attached
-- Orignal Message --
From: "mark sony" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Re: searching a string
___
Odomos - the only mosquito prot
Hi
It is giving the found status everytime even when there are no
strings:
My script:
#!/usr/local/bin/perl -w
#use strict;
#use warnings;
while () {
$string = "the\n\tlucky\n\t\tcoins";
if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coins(\s)*$/) {
print "Yup,exists.\n";
} else {
print "nope \n";
}
}
$string = "the\n\tlucky\n\t\tcoin";
if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coin(\s)*$/) {
print "Yup";
}
What I would do is elliminate all the extra white space;
s/\w/ /g; s/\r\n/ /g;
then do a match.
/the lucky coin/;
Dennis
- Original Message -
From: "mark sony" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 18, 2003 02 13
Subject: searching
Hi
i am searching for a string of consecutive words say "the lucky
coin"
These may be in one line or different line separated by blank
lines such as
1>the
lucky coin
2>thelucky
coin
3>the
lucky coin
Whats the way in perl ?
mark
___