in reply to GREP/Regex - Locating Words in Sentences

You could extend this as necessary to accomodate a longer list of words to be tested.
$word = shift; %sent = ( one => "This is sentence one. I wonder what the word is.", two => "This would be sentence two.", thr => "Is this sentence three. I think it is. I sure hope it is.", ); @matches = grep $sent{$_} =~ /\b$word\b/, keys %sent; print "The matching sentences are:\n"; for (@matches) { print; print " => ", $sent{$_}, "\n"; }
Note that grep also makes use of regular expressions(in this case anyway). So realize that it may not have been your regular expressions that weren't working but rather the logic of your code.

Hope this helps ;0)




Amel