Mega Code Archive

 
Categories / Perl / Regular Expression
 

Word-Boundary Pattern Anchors

\b and \B, specify whether a matched pattern must be on a word boundary or inside a word boundary.  The \b pattern anchor specifies that the pattern must be on a word boundary.  /\bdef/ matches only if def is the beginning of a word.  \b to indicate the end of a word.  /def\b/ matches def and abcdef /\bdef\b/ matches only the word def.