bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/JavaScript/Working with Data
JavaScript•Working with Data

JavaScript RegExp Patterns

Concept visual

JavaScript RegExp Patterns

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Full RegExp Flag Reference

Revised July 2025

Flags can be added to a regexp pattern to

Modify its behavior:

Flag

Description

/d Performs substring matches (new 2022) /g Performs a global match (find all) /i

Performs case-insensitive matching

/m

Performs multiline matching

/s Allows . (dot) to match line terminators (new 2018) /u Enables Unicode support (new 2015) /v

Formula

An upgrade to the /u flag for better Unicode support (new 2025)

/y Performs a "sticky" search (new 2015)

See Also:

JavaScript RegExp Flags Tutorial

Full Character Classes Reference

Revised July 2025

A character class is one or more characters enclosed in square brackets [ ]

Class

Description

[a]

Matches the character between the brackets

[^a]

Matches all characters NOT between the brackets

[abc]

Matches all characters between the brackets

[^abc]

Matches all characters NOT between the brackets

Formula

[a - z]

Matches all characters in the range from a to z

Formula

[^a - z]

Matches all characters NOT in the range from a to z

Formula

[0 - 9]

Matches all characters in the range from 0 to 9

Formula

[^0 - 9]

Matches all characters NOT in the range from 0 to 9

See Also:

RegExp Characters Classes Tutorial

Full Metacharacter Reference

Revised July 2025

Metacharacters are characters with a special meaning: a|b Matches a or b. Matches any (wildcard) character except line terminators \w Matches word characters (alphanumeric and _) \W

Matches non-word characters

\d

Formula

Matches digits (0 - 9)

\D

Matches non-digit characters

\s Matches whitespace characters (space, tab, newline) \S

Matches non-whitespace character

[\b]

Previous

JavaScript Array Const

Next

JavaScript RegExp Objects