Regex Flags Reference
JavaScript regular expressions accept single-letter flags after the closing slash (for example /pattern/gi). Each flag changes how the pattern matches. This is the full set supported by modern engines.
| Flag | Name | Effect |
|---|---|---|
| g | global | Find all matches, not just the first. |
| i | ignoreCase | Case-insensitive matching. |
| m | multiline | ^ and $ match at line breaks, not just string start/end. |
| s | dotAll | The dot (.) also matches newline characters. |
| u | unicode | Treat the pattern as a sequence of Unicode code points. |
| y | sticky | Match only from lastIndex; no scanning ahead. |
| d | hasIndices | Record start/end positions of each captured group. |
| v | unicodeSets | Upgraded Unicode mode with set notation and string properties. |
Frequently asked questions
Can I combine multiple regex flags?
Yes. Append them in any order after the closing slash, for example /foo/gims. Each flag is independent.
What is the difference between the u and v flags?
Both enable Unicode mode. The v flag (unicodeSets) is a superset that adds set operations and properties of strings. You cannot use u and v at the same time.