🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to JavaScript Notes
Topic #90

JS RegExp Patterns


Full RegExp Flag Reference

Revised July 2025

Flags can be added to a regexp pattern to Modify its behavior:

Col 1 Col 2
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 An upgrade to the /u flag for better Unicode support (new 2025)
/y Performs a "sticky" search (new 2015)

Note: 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 [ ]:

Col 1 Col 2
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
[a-z] Matches all characters in the range from a to z
[^a-z] Matches all characters NOT in the range from a to z
[0-9] Matches all characters in the range from 0 to 9
[^0-9] Matches all characters NOT in the range from 0 to 9

Note: See Also: RegExp Characters Classes Tutorial


Full Metacharacter Reference

Revised July 2025

Metacharacters are characters with a special meaning:

Col 1 Col 2
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 Matches digits (0-9)
\D Matches non-digit characters
\s Matches whitespace characters (space, tab, newline)
\S Matches non-whitespace character
[\b] Matches backspace characters
\0 Matches NULL characters
\n Matches new line characters
\f Matches form feed characters
\r Matches carriage returns characters
\t Matches tab characters
\v Matches vertical tab characters
\p{} Matches characters with given Unicode Property (new 2018)
\P{} Matches character NOT with the given Unicode Property (new 2018)
\ddd Matches a character by the octal number ddd
\xhh Matches a character by the hexadecimal number hh
\uhhhh Matches a Unicode character by the hex number hhhh

Note: See Also: RegExp Meta Characters Tutorial


Full RegExp Assertions Reference

Revised July 2025

Assertions consist of Boundaries and Lookarounds.

Boundaries matches at the beginning or the end of lines and words, Lookarounds mathes previos or subsequent patterns.

Col 1 Col 2
Char Description
^ Matches from beginning of a string, or the beginning of a line if the m (multiline) flag is set
$ Matches from the end of a string, or the end of a line if the m (multiline) flag is set
\b Matches from the beginning or end of a word
\B Matches NOT from the beginning or end of a word
(?=...) Matches the subsequent string
(?!...) Matches NOT the subsequent string
(?<=...) Matches the previous string (new 2018)
(?<!...) Matches NOT the previous string (new 2018)

Note: See Also: RegExp Assertions Tutorial


RexExp Quantifiers

Quantifiers indicate the numbers of characters or expressions to match:

Col 1 Col 2
Code Description
x+ Matches at least one x
x* Matches zero or more occurrences of x
x? Matches zero or one occurrences of x
x{n} Matches n occurences of x
x{n,m} Matches from n to m occurences of x
x{n,} Matches n or more occurences of x

Note: See Also: RegExp Quantifiers Tutorial

Want to go beyond the notes?

Join CodingNow 2.0's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

JS RegExp Patterns – FAQs

Quick answers about learning JS RegExp Patterns in JavaScript.

This free note from CodingNow 2.0 explains JS RegExp Patterns in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on CodingNow 2.0, including JS RegExp Patterns, is 100% free with no signup required.
With focused practice, most students grasp JS RegExp Patterns in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now