Hi all,
I am trying to figure out how to construct a regex that will match words
containing a 'subword'. For example: all words containing 'ain',
including pain, main, sain't
My rudimentary test code:
my $text = "pain the rain in spain falls mainly on the plains.the
meaning of \n".
"ain't that cool?saint sistine chapel";
while ($text =~ /\b(\S*?ain\S*?)\b/g)
{
print $1."\n";
}
failed for words ain't and saint
I tried to throw away \b:
while ($text =~
/[?\s,\.\?\!\(\)]([^\s,\.\?\!\(\)]*?ain[^\s,\.\?\!\(\)]*?)[?\s,\.\?\!\(\)]/g)
but that created another set of problems: I can't catch the first word
in the string, and the regex looks really ugly.
Can anyone write a better regex? Please advise. Thanks.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs