Regular Expression

suggest change

Syntax

Parameters

Flags Details
g global. All matches (don’t return on the first match).
m multi-line. Causes ^ & $ to match the begin/end of each line (not only begin/end of string).
i Case-insensitive matching. With u or v, case folding is Unicode-aware.
u Unicode mode. The pattern is interpreted as code points, not lone UTF-16 code units. It cannot be combined with v.
y Sticky: match only at lastIndex, not at a later index.

d, s, and v are described on the flags page linked below. Without u or v, a pattern uses UTF-16 code units.

The RegExp object is only as useful as your knowledge of Regular Expressions is strong. See here for an introductory primer, or see MDN for a more in-depth explanation.

Creating a RegExp Object

RegExp Flags

Check if string contains pattern using .test

Matching With .exec

Using RegExp With Strings

RegExp Groups

Replacing string match with a callback function

Using Regex.exec with parentheses regex to extract matches of a string

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents