Test regular expressions live with match highlighting, capture groups, and all flags. JavaScript (ES2023) engine.
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to find, match, replace, or validate text. For example, the regex \d+ matches one or more digits, and [a-z]+ matches one or more lowercase letters.
The main JavaScript regex flags are: g (global — find all matches, not just first), i (case-insensitive), m (multiline — ^ and $ match start/end of each line), s (dotAll — dot matches newlines too), and u (unicode).
.* matches zero or more characters (including empty). .+ matches one or more characters (at least one is required). For example, .* matches an empty string but .+ does not.
Capture groups are parts of a regex enclosed in parentheses (). They capture the matched text for later use. For example, (\d{4})-(\d{2})-(\d{2}) matches a date and captures year, month, and day as separate groups. Named groups use the syntax (?<name>...).
Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, <.+> greedily matches the entire string <b>bold</b>. <.+?> lazily matches just <b> then </b> separately.