Regex Tester
Tests a regular expression against sample text, showing matches, capture groups and flags.
Pattern
JavaScript regex syntax help
Characters and classes
- .
- any character except line breaks (all of them with the s flag)
- \d \w \s
- digit, word character [A-Za-z0-9_], whitespace
- \D \W \S
- the opposite of each
- [abc] [^abc] [a-z]
- one of, none of, a range
- \p{L} \p{N}
- Unicode letter / number (needs the u or v flag)
- \. \* \\
- a literal . * \ (escape special characters)
Anchors and boundaries
- ^ $
- start / end of the text (of each line with the m flag)
- \b \B
- word boundary / not a word boundary
Quantifiers
- * + ?
- 0 or more, 1 or more, 0 or 1 (greedy)
- {n} {n,} {n,m}
- exactly n, at least n, n to m
- *? +? ??
- lazy versions — as few as possible
Groups and lookaround
- ( … )
- capturing group → $1, $2 …
- (?<name> … )
- named group → $<name>
- (?: … )
- group without capturing
- a|b
- a or b
- (?= … ) (?! … )
- followed by / not followed by
- (?<= … ) (?<! … )
- preceded by / not preceded by
- \1 \k<name>
- back-reference to a group
Flags
- g
- find every match (otherwise only the first)
- i m s
- ignore case · ^ and $ per line · . matches newlines
- u v
- Unicode mode (v adds set operations); use one, not both
- y d
- sticky (match at lastIndex only) · record group indices
Replacement text
- $& $1 $<name>
- whole match, group 1, named group
- $` $'
- text before / after the match
- $$
- a literal $
This is the JavaScript dialect your browser runs. Other engines (PCRE, Python, POSIX grep) differ — for example in possessive quantifiers, inline flags and \A / \z anchors, which JavaScript does not have.
Matches
Runs entirely in your browser. Your input is not uploaded or stored.
How the method works
Characters outside the Basic Multilingual Plane, such as most emoji, take two code units, so one emoji moves later offsets by 2. Fixed example values for illustration — not your result.
How to use this calculator
- Enter a JavaScript pattern (without slashes), its flags and some test text.
- See every match highlighted, its [start, end) position, capture groups and named groups. Step through matches with Previous / Next or Alt+↓ / Alt+↑, open the syntax help for the JavaScript dialect, and tick Replace to preview a replacement.
- If a pattern runs too long it is stopped at your time limit and your input is kept.
How it works
Each run happens in a separate worker that is terminated at the deadline, so a pattern with catastrophic backtracking cannot freeze the page. A newer run always replaces an older one.
Positions are JavaScript UTF-16 code units. Empty matches advance by one character — a whole emoji when the u or v flag is set.
Unknown or duplicate flags are rejected before running. Text is limited to 1 MiB and the list to the first 1,000 matches.
Worked example
\d+ on 'a12 b3'. Matches '12' at [1, 3) and '3' at [5, 6).
Common mistakes
- Nesting quantifiers such as (a+)+ — they can take exponential time on near-misses.
- Forgetting the g flag and seeing only the first match.
- Assuming a pattern is safe because one sample finished quickly.
Tips
- Runs entirely in your browser. Your input is not uploaded or stored.
Frequently asked questions
Which flavour?
JavaScript regular expressions (the same engine the browser uses).
Privacy?
Runs entirely in your browser. Your input is not uploaded or stored.
Related tools
- Text Diff Checker
- Word & Character Counter
- Case Converter
- Cron Expression Parser
- HTML Encoder / Decoder
- HTML to Markdown Converter
Explore more in PDF, Image, File, Data & Developer Tools.
Cite this tool
Zerdly. (2026). Regex Tester. Retrieved from https://www.zerdly.com/tools/regex-tester/
Tip: Enter any known values to calculate the remaining results.
Designed to run locally in your browser. Tool inputs are not intentionally stored by Zerdly unless stated otherwise.



