RegExp \ b metacharacter
Definition and Usage
\ B metacharacter matches a word boundary.
\ B metacharacter is usually used to find the matching word located at the beginning or end.
grammar
new RegExp("\bregexp")
或者更简单方式:
/\bregexp/
或者更简单方式:
/\bregexp/
Browser Support
All major browsers support \ b metacharacter
Examples
Examples
To the beginning or end of a string of words were "W3" global search:
var str="Visit W3CSchool";
var patt1=/\bW3/g;
var patt1=/\bW3/g;
The marked text below shows where the expression gets a match
Visit W3 Cschool
try it"
JavaScript RegExp Object