Regex Tester Online Free
Write a regular expression and test it against any string with live match highlighting. See capture groups, match positions, and counts instantly. Runs entirely in your browser.
Matches
Replace preview
Quick reference
.any character except newline\ddigit, same as [0-9]\wword character, [A-Za-z0-9_]\swhitespace\bword boundary^ $start and end of string*zero or more+one or more?zero or one{2,5}between two and five+?lazy, match as few as possible(...)capture group(?:...)group without capturing(?<n>...)named capture group(?=...)lookahead(?<=...)lookbehind[abc]any one of a, b or c[^abc]anything except a, b or cWhy matching runs in the background. Some patterns take exponential time. The classic shape is a quantifier inside a quantifier, like (a+)+$, which forces the engine to try every possible way of splitting the input before it can conclude there is no match. Thirty characters can take minutes; forty can take longer than you will keep the tab open.
JavaScript runs on a single thread and a regex cannot be interrupted once started, so a pattern like that will freeze the whole page with no way to cancel. This tool runs every match in a background worker with a 1.5 second limit, and kills the worker if it overruns. You get an explanation and a working page instead of a locked tab.
The fix for a slow pattern is usually to remove the ambiguity rather than to optimise it. (a+)+$ matches exactly the same strings as a+$, but the second one has only one way to match, so the engine never has to backtrack.
A regex tester built directly on JavaScript’s own RegExp engine
This is not an emulator of another language’s regex flavor. Every pattern you type is compiled with new RegExp(pattern, flags), the exact constructor JavaScript itself uses, so what matches here is precisely what will match in your code. Matching, highlighting, and the capture group breakdown all run client-side with no network request involved anywhere in the script.
How matches are collected
With the global flag on, a single exec() call only returns one match at a time and advances lastIndex internally. The tool loops that call until it returns null, pushing each match’s text, start index, end index, and capture groups into an array as it goes.
SyntaxError whose message is shown directly in the status bar instead of a generic failure.
exec() on the same regex object, which is stateful and remembers where it left off via lastIndex.
a*, would otherwise return the same zero-length match forever at the same index. The loop manually increments lastIndex whenever a match has zero length.
The five flags, and what each changes
| Flag | Effect |
|---|---|
| g | Global. Without it, only the first match in the string is found and shown, no matter how many times the pattern could match. |
| i | Case insensitive matching for both literal characters and character classes. |
| m | Multiline. Makes ^ and $ match the start and end of each line rather than only the start and end of the whole string. On by default in this tool. |
| s | Dot-all. Lets . match newline characters, which it otherwise never does. |
| u | Unicode mode. Treats the pattern and subject as sequences of Unicode code points instead of UTF-16 code units, which matters for characters outside the Basic Multilingual Plane, like many emoji. |
^ and $ will suddenly only match the very start and end of the whole string instead of each line, a common source of copy-paste bugs when moving between the tester and production code.Highlighting and the sample library
Color cycling
Matches are wrapped in span tags cycling through four highlight classes by index modulo four, so overlapping-looking adjacent matches are still visually distinguishable from one another.
Seven built-in samples
Email, URL, phone, date, IPv4 address, hex color, and a capture-group demo, each preloaded with a working pattern, matching flags, and realistic test text.
Clickable cheat sheet
22 reference tokens, from \d to lookaheads, insert directly at the cursor position in the pattern field when clicked.
Regex engines and references
- MDN: JavaScript regular expressions guide is the authoritative reference for the exact syntax this tool executes.
- ECMA-262, the RegExp specification defines the formal grammar and flag behavior.
- regex101 is a well known alternative if you need a step-by-step engine debugger across multiple language flavors, not just JavaScript.
- MDN: RegExp.prototype.exec() documents the
lastIndexstatefulness this tool’s matching loop depends on.
Patterns people test here
Writing and verifying form validation patterns before shipping them, extracting structured data like phone numbers or IDs from a block of pasted text, debugging why a pattern in production is not matching what you expect, teaching regex fundamentals with immediate visual feedback, and quickly checking whether a log line format matches a parsing pattern before wiring it into a script.
FAQ: Regex Tester Online Free
Yes, completely free. No account, no signup, and no payment required.
The tool uses JavaScript regex, which is the same engine used in Node.js and all major browsers. Patterns that work here will work directly in JavaScript code. There are minor differences between JS and other flavors like Python or PCRE, but most common patterns behave identically.
The g flag stands for global. Without it, the regex stops after finding the first match. With g enabled, it finds all matches in the string. Most use cases need the g flag on.
Capture groups are portions of your pattern wrapped in parentheses. They extract specific parts of a match. For example, the pattern (\w+)\s(\w+) matches two words and captures each one separately in Group 1 and Group 2. The tool shows the value of each capture group for every match.
The m flag is multiline mode. It makes ^ match the start of each line instead of just the start of the whole string, and $ match the end of each line. The s flag is dotAll mode. It makes the dot character match any character including newlines, which by default it does not.
Click any token in the quick reference panel at the bottom of the tool. It inserts that token directly at the cursor position in the pattern input. This saves you from having to remember the exact syntax for each token.
From the blog
Deep dives on the things these tools touch
Minification, UUID collisions, diffing API responses, and the other questions that come up around this toolset.