in reply to Regular Expressions \b and \B
When the RE engine encounters the \b metacharacter, it tells the engine to look not only look at the character after the invisible spaces but also at the character before the invisible space. The engine then compares the two characters to eachother and asks a question: "Is the character to the left of me a non-word character (that is anything except a number, a letter, or an underscore), and is the character to the right of me a word character?" If this is the case, then the RE will find a match because it recognizes this invisible space as a "word boundary" and that it is between a non-word character and a word character. Note that this is also true at the end of a word except that it has a word character to the left and a non-word character to the right.
Hope this helps. Let me know if you have specific questions.
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot";
$nysus = $PM . $MCF;
|
|---|