Boundaries

In the following table, you can find the patterns for boundaries, which will tell the Regex what position to do the matching in.

Pattern

Description

Example

^

This matches the beginning of an input. If the multiline flag is set to true, it also matches immediately after the ( ) line break character.

/^ The/ matches "The" in "The stars", but not "In The stars".

$

This matches the end of an input. If the multiline flag is set to true, it also matches immediately before the ( ) line break character.

/and$/ matches "and" in "land", but not "and the bar".



This matches any word boundary (test characters must exist at the beginning or at the end of a word within the string).

/va/ matches "va" in "this is a java script book", but not "this is a javascript book".

B

This matches any non-word boundary.

/vaB/ matches "va" in "this is a JavaScript book", but not "this is a JavaScript book".

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset