JavaScript RegExp \B metacharacter
JavaScript RegExp Object
Definition and Usage
The \B metacharacter matches a non-word boundary. The character before and after the match position must be of the same type: both must be word characters, or both must be non-word characters. The start and end of a string are treated as non-word characters.
If no match is found, null is returned.
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 "noob" that is not at the start or end of a word in the string:
var
str
=
"
Visit Runoob
"
;
var
patt1
=/\
Bnoob
/
g
;
The text marked below shows where the expression found matches:
Visit Ru
noob
Try it »
JavaScript RegExp Object