See also Defining Characters in Word Boundary?.
Based on the suggestion in the first reply there:
my $string_to_check = "yyy foo-bar doo zzz"; my $set = '[\w-]'; my $b = qr/(?<=$set)(?!$set)|(?<!$set)(?=$set)/; for my $check ("foo-bar doo", "bar doo") { if ($string_to_check =~ /$b$check$b/) { print "$check matched\n"; } }
In reply to Re: Word boundary in regexp
by Eliya
in thread Word boundary in regexp
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |