JavaScript RegExp \b and \B Metacharacter

The regex "\b" shows the available start or end of the character in the input string in JavaScript. The regex "\b" shows the character's unavailable start or end in the JavaScript input string. We can test, search, and match the arability of the required character in the string.

Syntaxes

JavaScript "\b" regex syntax

The syntax is used to show available characters at the start of the string.

The syntax shows the available character at the end of the string.

JavaScript "\B" regex syntax

The syntax shows an unavailable character at the start of the string.

The syntax shows the not available character at the end of the string.

Examples

JavaScript "\b" regex Examples

The examples show the availability of the character at the start or end of the string.

Example1

The example shows the availability of the required character at the start of the string.

Output

The output shows the required character at the starting position.

JavaScript RegExp \b and \B Metacharacter

Example2

The example shows the availability of the required character at the end of the string.

Output

The output shows the required character at the starting position.

JavaScript RegExp \b and \B Metacharacter

Example3

The example tests of the required character are available at the start of the string with the case-sensitive input value.

Output

The output shows the case-sensitive character of the beginning position.

JavaScript RegExp \b and \B Metacharacter

JavaScript "\B" regex Examples

The examples show no character availability at the start or end of the string.

Example1

The example shows the required character is unavailable at the start of the string.

Output

The output shows the required character, not at the beginning position.

JavaScript RegExp \b and \B Metacharacter

Example2

The example shows the not available required character at the end of the string. We can get the regular expression or required character to search for the end position.

Output

The output shows the required character, not the ending position.

JavaScript RegExp \b and \B Metacharacter

Example3

The example tests are not available for the required character at the start of the string with the case-sensitive input value. The lowercase data does not test the uppercase character of the string.

Output

The output shows the case-sensitive character of the beginning position.

JavaScript RegExp \b and \B Metacharacter

Conclusion

The "\b" and "\B" metacharacter of the regular expression shows the start and end position of the value.






Latest Courses