We don't bite newbies here... much | |
PerlMonks |
Regex word boundary and escaped charactersby ryantate (Friar) |
on Jan 26, 2005 at 23:04 UTC ( [id://425413]=perlquestion: print w/replies, xml ) | Need Help?? |
ryantate has asked for the wisdom of the Perl Monks concerning the following question: The regex word boundary meta character, \b, does not seem to match start of string if the first word character of the string is escaped. Is this expected behavior? Here is an example of the behavior in question:
For now I'm using (\b|^)\@testing(\b|$) as a workaround, but this behavior seems at odds with perlre, which states: A word boundary ( \b ) is defined as a spot between two characters that has a \w on one side of it and and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W . Is this a bug? Update: No, of course, it's not a bug. @ and + being non word chars, there is no \w char to match. Duh. ;--> Thanks for the many quick responses.
Back to
Seekers of Perl Wisdom
|
|