Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Regex Help

Name: Anonymous 2010-09-13 6:49

I am fairly new to perl and even newer to regular expressions, so if you can improve on this at all go on ahead. However, that isn't really why I came here. Basically, I want it to return true if the word(s) after "going/gonna (to)" equal either bed, sleep, nap or rest. I can't get it to work and whenever it comes close to working, it just returns true for any following word, which is not what I want.

I have this:


if($arg =~ /^I( am|'m)? go[naing]?([ to]*) /i)
{
# some code here
}


Any help is appreciate and again, if you can improve this at all, please do.

Name: Anonymous 2010-09-13 10:39

#!perl

my $s_Text = shift;
print "Testing for '$s_Text'\n";
my $b_Match = ($s_Text =~ /.*(going|gonna|gonna to|)\s+(bed|sleep|nap|rest).*/i)?1:0;

print $b_Match.$/;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List