LPM: regexp question

Matt Cashner sungo at brocksplace.com
Tue Dec 21 01:01:05 CST 1999


all righty then. what i'm trying to do is to determine if the words 
"is" and "are" are  one of the first five words in a sentence. the code
i'm using now looks like this: (yes, its ugly and newbie-ish)

my ($stu_foo,$stu_blah, at stu_search, at stu_refs,$stu_term);
$stu_term = $orig_Y;
@stu_search = ('is','are');
$theMsg =~ /(\w*)\s*(\w*)\s*(\w*)\s*(\w*)\s*(\w*).*?/;
@stu_refs = ($1,$2,$3,$4,$5);
foreach $stu_blah (@stu_refs) {
   foreach $stu_foo (@stu_search) {
      if ($stu_blah =~ /\b$stu_foo\b/ or $stu_blah =~ /\b$stu_term\b/) {
          $theMsg = "<reply> $who: $theMsg";
          goto OUT;
      }
   }
}
OUT:

anyway, is there a better way to do this? this seems awfully hackish to
me... thanks for your help all...

---------------------
Matt Cashner
 sungo at earthling.net
---------------------

"In the battle between you and the world, bet on the world."




More information about the Lexington-pm mailing list