0% found this document useful (0 votes)
3 views10 pages

Module - 2 JavaScript RegExp Patterns

The document provides an overview of JavaScript Regular Expressions (RegExp) patterns, including syntax for creating RegExp objects and various flags that modify their behavior. It details character classes, metacharacters, assertions, groups, and quantifiers used in RegExp, along with their descriptions. Additionally, it mentions browser support for RegExp as an ECMAScript1 feature.

Uploaded by

lifewithvndv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Module - 2 JavaScript RegExp Patterns

The document provides an overview of JavaScript Regular Expressions (RegExp) patterns, including syntax for creating RegExp objects and various flags that modify their behavior. It details character classes, metacharacters, assertions, groups, and quantifiers used in RegExp, along with their descriptions. Additionally, it mentions browser support for RegExp as an ECMAScript1 feature.

Uploaded by

lifewithvndv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript RegExp Patterns [Link]

asp

 Tutorials  References  Exercises  Certificates  Search... Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

JavaScript RegExp Patterns


❮ Previous Next ❯

New to RegExp?
Visit Our JavaScript RegExp Tutorial

1 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]

 Tutorials  References  Exercises  Certificates  Sign In

 let regexp
HTML CSS =JAVASCRIPT
/pattern/flags;
SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP
// or
let regext
REMOVE ADS = new RegExp(pattern, flags)

RexExp Flags / Modifiers


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 An upgrade to the /u flag for better Unicode support (new 2025)

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

2 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]


RexExp Character
Tutorials  References 
Classes
Exercises  Certificates  Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP
A character class is one or more characters enclosed in square brackets:
REMOVE ADS
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

RexExp Metacharacters
Metacharacters are characters with a special meaning:

a|b Matches a or b

3 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]


. TutorialsMatches
 any (wildcard)
References  characterexcept
Exercises line terminators
Certificates  Sign In

\w Matches word characters (alphanumeric and _)


HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

\W Matches non-word characters


REMOVE ADS
\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

4 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]


\xhh TutorialsMatches
 a character
References  by Exercises
the hexadecimal
 number hh
Certificates  Sign In

\uhhhh Matches a Unicode character by the hex number hhhh


HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

REMOVE ADS

RexExp Assertions
Assertions include boundaries, which indicate the beginnings and endings of lines and words:

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)

RexExp Groups

5 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]

 Tutorials  Groups
Regular Expression References Exercises
(aka capturing
 groups) parts of a matched string to be extracted and reused. They are Sign In
Certificates
 allows
created by enclosing a pattern within parentheses ():
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

Char Description
REMOVE ADS

(x) Matches x and remembers the match

(?<n>x) Matches x and labels it n

(?flag:x) Enables flag(s) for x

(?flag-flag:x) Disables flag(s) for x

REMOVE ADS

RexExp Quantifiers
Quantifiers indicate the numbers of characters or expressions to match:

Code Description

x+ Matches at least one x

x* Matches zero or more occurrences of x

x? Matches zero or one occurrences of x

6 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]


x{n} Tutorials  Matches noccurences
References ofx
Exercises Certificates  Sign In

x{n,m} Matches from n to m occurences of x


HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

x{n,} Matches n or more occurences of x


REMOVE ADS

See Also:
JavaScript RegExp Methods

Browser Support
/regexp/ is an ECMAScript1 (JavaScript 1997) feature.

It is supported in all browsers:

Chrome Edge Firefox Safari Opera

❮ Previous Next ❯

7 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]

 Tutorials  References  Exercises  Certificates  Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

REMOVE ADS

COLOR PICKER

 

8 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]

 Tutorials  References  Exercises  Certificates  Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C C++ C# BOOTSTRAP

--> REMOVE ADS


 PLUS SPACES GET CERTIFIED

FOR TEACHERS FOR BUSINESS CONTACT US

Top Tutorials Top References


HTML Tutorial HTML Reference
CSS Tutorial CSS Reference
JavaScript Tutorial JavaScript Reference
How To Tutorial SQL Reference
SQL Tutorial Python Reference
Python Tutorial [Link] Reference
[Link] Tutorial Bootstrap Reference
Bootstrap Tutorial PHP Reference
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial AngularJS Reference
jQuery Tutorial jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

9 of 10 05-01-2026, 13:11
JavaScript RegExp Patterns [Link]

 Tutorials  References  Exercises  Certificates  Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP  HOW
   TO [Link] C C++ C# BOOTSTRAP

REMOVE ADS FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].

10 of 10 05-01-2026, 13:11

You might also like