Regex Tester - Live Matches, Named Groups, Replace
Test JavaScript regular expressions against live text with highlighted matches, numbered and named capture groups, a replace preview, and all six flags. Runs in your browser.
Regular expression
Test string
Match results
5 matchesTesting against the engine you will actually run
A regular expression is a compact description of a set of strings: a pattern that a text either matches or does not. The catch is that there is no single regex language. JavaScript, Python, PCRE, Java, and the POSIX tools each support slightly different syntax and features, so a pattern that is perfect in one can be invalid or subtly wrong in another. This tester compiles your pattern with the browser’s own ECMAScript engine, which means what you see here is exactly what a browser or Node.js will do, and it is the right place to test regex destined for JavaScript.
As you type, the pattern is applied to the test string and every match is highlighted in place. The highlight layer sits behind the text and scrolls with it, so on a long input the colours stay lined up with the characters they mark rather than drifting as you scroll, a small detail that makes a real difference when you are scanning a wall of log lines. Below the text, each match is broken out with its position and its capture groups so you can see not just that the pattern matched, but what each part of it captured.
Numbered and named groups
Parentheses in a pattern capture the text they match. Traditionally you refer to those captures by number, in the order the opening parentheses appear, and the tool lists them that way for every match. Modern JavaScript also supports named groups written (?<name>...), which are far easier to read and maintain than counting positions. This tester shows named groups in their own block, and in replace mode you can reference them with $<name> instead of a fragile numeric back-reference.
The zero-width trap
Some patterns match without consuming any characters: a* can match nothing, a word boundary \b marks a position, and a lookahead asserts without moving. With the global flag these zero-width matches occur at many spots. Naive matching code that forgets to advance past them spins forever, which is a classic bug. This tool advances past each one, so it stays responsive, counts the matches honestly, and shows a note explaining why there is nothing to highlight at those positions.
What the flags change
The six flags each change one thing. g (global) keeps finding matches after the first instead of stopping. i (ignore case) makes letters match regardless of case. m (multiline) makes ^ and $ match at every line break rather than only the very start and end of the text. s (dotall) lets . match newline characters, which it normally does not.
The last two are less familiar but useful. u (unicode) makes the engine treat the pattern as Unicode code points, which is what you want when working with emoji or non-Latin scripts, and it enables Unicode property escapes. y (sticky) anchors each match to the exact position where the last one ended, which is how tokenizers walk through input one piece at a time without skipping ahead. Toggling any flag re-runs the match immediately so you can see its effect.
One caution worth carrying from here into production code: JavaScript’s engine can be made to work extremely hard by patterns with nested, overlapping quantifiers. Against the right input, something like (a+)+$ triggers catastrophic backtracking and the match appears to hang. It is harmless while you experiment here, but when the same pattern runs on a server against text a user controls, it becomes a denial-of-service risk, so prefer specific, non-overlapping pieces and anchor where you can.
Related tools
Once a pattern extracts the data you want, the JSON Formatter will format and validate a JSON result, and the Diff Checker helps compare the text before and after a replace to confirm exactly what changed.
How to Use
Type your pattern between the slashes, without the enclosing slashes themselves.
Toggle any of the six flags: g, i, m, s, u, y.
Type or paste text into the test string box; matches highlight as you type.
Read each match below, with its index, numbered capture groups, and any named groups.
Turn on Replace mode to preview the result of a replace, using $1 or $<name> in the replacement.
Features
Common Questions
Use this regex tester to build and debug JavaScript regular expressions against live text, with matches highlighted as you type, numbered and named capture groups shown for each match, and a replace-mode preview that supports $1, $& and $<name>. Toggle all six flags (global, ignore case, multiline, dotall, unicode, sticky), and see zero-width matches handled safely rather than breaking the display. Everything runs in your browser, so patterns and sensitive test text stay on your device.
About Regex Tester
Build and debug JavaScript (ECMAScript) regular expressions against live text, with matches highlighted as you type and a highlight layer that scrolls in step with the input. Each match breaks out its index, its numbered capture groups, and any ES2018 named groups written (?<name>...). Toggle all six flags (g, i, m, s, u, y), and switch on replace mode to preview a find-and-replace using $1, $& and $<name>. Zero-width matches are handled safely with a clear note instead of a broken display or an infinite loop, and everything runs in your browser so patterns and sensitive test text never leave your device.
Also known as: test regex, regular expression tester, regex matcher, regex debugger, regexp online, regex replace, named capture groups, javascript regex, regex flags, regex validator, pattern matcher, regex playground.
Processing Note
Regex Tester runs in your browser, so the input you enter is processed locally on this page and is not uploaded to a ToolMintX account.
Tool Limits
IT tools provide quick diagnostics and transformations. They cannot see every private network, deployment setting, proxy, firewall, or production edge case.
Explore More
AI VRAM Calculator
Estimate GPU VRAM for LLM inference and training using model, quantization, users, and context length.
Client-sideAI API Cost Calculator
Compare and estimate AI API costs across OpenAI, Claude, Gemini, DeepSeek and more for text, image, video, and embeddings.
Client-sideAPI Key and .env Secret Generator
Generate secure .env secrets plus selectable Hugging Face, OpenAI, JWT, database, and webhook variables.
Client-sideSubnet Calculator
IPv4 subnet calculator: network and broadcast address, subnet and wildcard mask, usable host range, and host count from any IP and CIDR prefix.
Client-side