Hello
middle
worldRegex Flags Tester & Guide
Toggle JavaScript regular-expression flags and see the result immediately. Compare global matching, case-insensitive behavior, multiline anchors, dotAll, Unicode, sticky matching, and match indices using the same pattern and test text.
What changes with these flags?
JavaScript regex flags explained
g — Global
Return repeated matches instead of stopping after the first match.
i — Ignore case
Match letters without requiring the same uppercase/lowercase casing.
m — Multiline
Make ^ and $ work at line boundaries as well as the beginning and end of the whole string.
s — DotAll
Allow . to match line terminators such as newline characters.
u — Unicode
Use Unicode-aware code-point semantics and stricter Unicode escape handling.
y — Sticky
Require the next match to begin exactly at RegExp.lastIndex instead of searching forward.
d — Indices
Expose start/end indices for the full match and capture groups through match.indices.
Flags change behavior, not the pattern text
The same source can behave very differently under different flags. For example, ^cat$ checks the entire input without m, but can match an individual line when multiline mode is enabled. Likewise, . does not normally cross a newline unless s is active.
Need deeper match inspection?
Use the Capture Group Explorer when the important question is what each group captured, or the Regex Tester for a broader custom-regex sandbox.
Frequently asked questions
What are regex flags?
Regex flags change how a regular expression is interpreted or how matching proceeds. In JavaScript they are supplied after a regex literal, such as /hello/gi, or as the second argument to new RegExp("hello", "gi").
What is the difference between g and m?
The g flag controls repeated matching across the input. The m flag changes the meaning of ^ and $ so they can match at line boundaries. They solve different problems and are often used together.
What does the s flag do in JavaScript regex?
The s or dotAll flag allows the dot metacharacter to match newline and other line-terminator characters. Without s, . normally stops at a line terminator.
When should I use the u flag?
Use u when your pattern needs Unicode code-point semantics, Unicode escapes, or behavior that treats astral characters more predictably. It can also make otherwise ambiguous or invalid escape syntax fail fast.
What is the d regex flag?
The d or hasIndices flag asks JavaScript to expose start/end index pairs for matches and capture groups. It does not change which text matches; it adds location metadata to the result.