JavaScript RegExp \bMetacharacter
JavaScript RegExp Object
Definition and Usage
The \b metacharacter matches word boundaries.
The \b metacharacter is usually used to find matches at the beginning or end of a word.
Syntax
new RegExp("\bregexp")
Or in a simpler way:
/\bregexp/
Or in a simpler way:
/\bregexp/
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the \b metacharacter
Example
Example
Perform a global search for "Run" at the beginning or end of words in a string:
var str="Visit Runooob";
var patt1=/\bRun/g;
BelowmarkedThe text shows where the expression gets matches
Visit Runoob
Try it yourself »
JavaScript RegExp Object
Other Extensions