Regular-expression flags
suggest changeFlags change how a regular expression matches. Append them to a literal, as in /test/gi, or pass them as the second argument to the constructor: new RegExp("test", "gi").
| Flag | Meaning |
|---|---|
d |
Include match indices in the result. |
g |
Find successive matches instead of stopping after the first. |
i |
Perform case-insensitive matching. Unicode case folding means this is not always equivalent to writing both ASCII cases manually. |
m |
Make ^ and $ match the start and end of each line as well as the start and end of the input. |
s |
Allow . to match line terminators. |
u |
Interpret the pattern as Unicode code points and enable Unicode-aware syntax. |
v |
Enable Unicode-sets mode, including set operations in character classes. It cannot be combined with u. |
y |
Match only at lastIndex (sticky matching). |
The g and y flags make methods such as exec() update the expression's lastIndex. Reusing the same regular-expression object can therefore affect later matches.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents