Neither ' ', '&', nor ';' are word characters, so there is no word boundary between them.
On the other hand, 'a', and 'f' are word characters (and '&' and ';' still aren't), so there are your word boundaries.
You probably want either negative or positive lookahead/lookbehind for (non-)whitespace instead. Negative version:
$str = 'abac ~~~ afa~~~ +;f'; $str =~ s|(?<!\s)\&\#x0007E\;\&\#x0007E\;\&\#x0007E\;(?!\s)|~~~|g; print $str;
Positive lookahead/lookbehind won't match at end/beginning of string:
$str = 'abac ~~~ afa~~~ +;f'; $str =~ s|(?<=\S)\&\#x0007E\;\&\#x0007E\;\&\#x0007E\;(?=\S)|~~~|g; print $str;
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
In reply to Re: Word boundary '\B' - Question
by Sidhekin
in thread Word boundary '\B' - Question
by prasadbabu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |