Common questions about regex syntax, flags, capture groups, and debugging patterns
What regex flavour does this tester use?
This tester uses JavaScript's built-in RegExp engine, which implements a subset of the PCRE (Perl Compatible Regular Expressions) standard. It supports all common regex features: character classes, quantifiers, anchors, lookaheads and lookbehinds, named capture groups, backreferences, and the standard flags (g, i, m, s, u, y). It does not support some PCRE-specific features like possessive quantifiers, atomic groups, or variable-length lookbehinds (though ES2018+ added fixed-length lookbehinds). Results match exactly what you'd get in a Node.js, browser JavaScript, or TypeScript application.
What do the regex flags mean?
g (global). Find all matches instead of stopping at the first. i (case insensitive). Match uppercase and lowercase equivalently. m (multiline). Make ^ and $ match the start and end of each line, not just the whole string. s (dotAll). Make the dot (.) match newlines as well as other characters. u (unicode). Enable full Unicode support for \p{} property escapes. y (sticky). Match only from lastIndex, not searching forward. You can combine flags freely. Gi finds all matches case-insensitively, gm matches across multiple lines.
How do capture groups work?
A capture group is a part of the regex wrapped in parentheses that captures the matched text as a separate result. For example, the pattern (\d{4})-(\d{2})-(\d{2}) applied to '2024-01-15' captures three groups: '2024', '01', and '15'. Named capture groups use (?<name>...) syntax. For example (?<year>\d{4}) names the first group 'year'. Groups are useful for extracting specific parts of a match, like pulling the domain from an email address or the year from a date string. This tool displays all capture groups alongside each match.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, ??, {n,m}?) match as little text as possible. For example, the pattern <.+> applied to '<b>bold</b>' greedy matches the entire string '<b>bold</b>' (from the first < to the last >). The lazy version <.+?> matches '<b>' (stopping at the first >). Greedy is the default. Add ? after any quantifier to make it lazy. This matters when matching HTML tags, quoted strings, or any content with nested delimiters.
What is a lookahead and lookbehind?
Lookaheads and lookbehinds are zero-width assertions that match a position based on what follows or precedes it, without including that text in the match. A positive lookahead (?=...) matches a position followed by the specified pattern. A negative lookahead (?!...) matches a position NOT followed by the pattern. Similarly for lookbehinds: (?<=...) and (?<!...). Example: \d+(?= dollars) matches numbers followed by ' dollars' but doesn't include ' dollars' in the match. These are essential for extracting values without their context strings.
How do I match special characters literally?
Characters with special meaning in regex, . * + ? ^ $ { } [ ] | ( ) \. Must be escaped with a backslash to match them literally. For example, to match a literal dot, use \. instead of . (which matches any character). To match a literal backslash, use \\. To match a literal opening parenthesis, use \(. In JavaScript string literals, you need to double-escape: the pattern for a literal dot in a JS string is '\\.'. In this tool's pattern field, use single escaping. Enter \. to match a literal dot.
How do I test a multiline string?
Paste or type multiple lines directly into the Test String text area. It supports newlines. For multiline matching, enable the m flag so that ^ and $ match the start and end of each line. Enable the s flag (dotAll) if you want the dot to match newline characters. Without s, a dot matches everything except \n, so patterns like .+ won't cross line boundaries. Without m, ^ only matches the very start of the entire string and $ only matches the very end.
Why is my regex matching too much or too little?
Over-matching (too much) is usually caused by greedy quantifiers or the dot matching more than expected. Try making quantifiers lazy (add ?) or use character classes instead of dots. Under-matching (too little) is often caused by missing the g flag (only first match returned), anchors that are too strict (^ or $ not matching as expected without the m flag), or character classes that don't include all needed characters. The visual highlighting in this tool makes it immediately clear exactly what is and isn't being matched, which is the fastest way to debug both problems.