Regex tester
Test a regular expression against sample text, with matches and capture groups shown.
How it works
Tests a JavaScript regular expression against sample text, listing every match with its position and capture groups.
Flags matter more than people expect. Without the global flag only the first match is returned; without multiline, the anchors ^ and $ match the start and end of the whole string rather than of each line. Most confusion about a regex that "does not work" comes down to one of those two.
A caution worth stating: a badly-formed regex can take exponential time on certain inputs, a failure known as catastrophic backtracking. Nested quantifiers like (a+)+ are the classic trigger. It matters because a regex run on user input is then a denial-of-service vector, and this is a genuine class of production incident rather than a theoretical concern.
This uses your browser’s own engine, so the behaviour matches JavaScript exactly. Other languages differ — lookbehind, named groups and Unicode handling all vary between PCRE, Python and Go.
This tool runs entirely in your browser. Nothing you enter is sent to a server, logged or stored, and the page keeps working with the network disconnected.
Common questions
- Why does my regex only match once?
- The global flag is missing. Without it, matching stops at the first result.
- What is catastrophic backtracking?
- A pattern whose matching time grows exponentially on some inputs, usually from nested quantifiers like (a+)+. Run on user input it becomes a denial-of-service vector.
- Will this regex work in Python?
- Not necessarily. This uses the JavaScript engine; lookbehind, named groups and Unicode handling all differ between engines.
Related pages
- Word and character counter Words, characters, sentences, paragraphs and reading time, counted as you type.
- Typing speed test Measure words per minute and accuracy on a one, two or five minute test.
- Remove duplicate lines Strip repeated lines from a list, keeping the first occurrence of each.
- Sort lines alphabetically Sort a list of lines A–Z, Z–A, by length, or numerically.
- JSON formatter and validator Pretty-print, minify and validate JSON, with the exact position of any error.
- Text compare Compare two blocks of text and see which lines were added, removed or changed.
- Case converter Convert text between upper, lower, title, sentence, camel, snake, kebab and other cases.
- Remove empty lines Delete blank lines from a block of text, optionally collapsing runs to one.
- Find and replace Replace every occurrence of a string in pasted text, with optional regex.
- Readability checker Flesch Reading Ease and grade level, with sentence length and passive voice flagged.
Sources
- Calculated on this page — At One Place