What are non-word boundary in regex (\B), compared to word-boundary?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A word boundary (
\b) is a zero width match that can match:\w) and a non-word character (\W) orIn Javascript the definition of
\wis[A-Za-z0-9_]and\Wis anything else.The negated version of
\b, written\B, is a zero width match where the above does not hold. Therefore it can match:For example if the string is
"Hello, world!"then\bmatches in the following places:And
\Bmatches those places where\bdoesn’t match: