Word boundary
In Perl-style regular expressions, the pattern does not have an implicit word boundary. For example, the regular expression test
matches the whole word test
but also any word that contains those characters, such as attest
, mytest
, testimony
, atestb
, etc.
Use the notation \b
to specify where a word must start or end. To match exactly and only the whole word test
, for example, the regular expression should be \btest\b
. See also Syntax.