in reply to Word Boundary Matching

I think you need to extend your match to include, either the start/end of the line or a single space, after radio. This will capture cases where radio is in the middle of a phrase, or if it is at the start or end of your sentence.

Use |s enclosed in parens to specify alternatives.

Try something like below:

#!/usr/bin/perl -w my @sentence_list = ( 'radiohead', 'turn off your radio', 'jill has a radio that is black', 'the stereo is broken', 'radio for happiness', ); foreach $sentence (@sentence_list){ if ($sentence =~ /(^|\W)radio(\W|$)/){ print "Found\n"; } else { print "Not found\n"; } }

This gives results:

Not found Found Found Not found Found