JavaScript RegExp \b metacharacter
JavaScript RegExp Object
Definition and Usage
The \b metacharacter matches a word boundary.
The \b metacharacter is commonly used to find matches at the start or end of a word.
Syntax
new RegExp("\b
regexp
")
Or a simpler way:
/\b
regexp
/
Browser support





All major browsers support the \b metacharacter
Example
Example
Perform a global search for "Run" at the start or end of words in the string:
var
str
=
"
Visit Runooob
"
;
var
patt1
=/\
bRun
/
g
;
The text marked below shows where the expression found matches.
Visit
Run
oob
Try it »
JavaScript RegExp Object