Free Regex Tester — Live Regular Expression Match Highlighter
A regular expression (regex) is a pattern used to match, search, and extract text. This tool tests your regex pattern against a test string in real time, highlights all matches, shows capture groups, and supports all JavaScript regex flags (g, i, m, s, u). No server round-trip — results update as you type.
developer
Test regular expressions against strings with live match highlighting.
- Live regex match highlighting as you type — no button press needed
- Capture group and named group (?<name>...) display with positions
- All JavaScript flags: g, i, m, s, u, y — toggleable independently
- Regex replace / substitution mode with $1, $2, $<name> backreferences
- Match count and character position for every result
- Built-in syntax cheat sheet — tokens, quantifiers, anchors, lookarounds
- Client-side only — patterns and test text are never uploaded
Everything you need in one Regex Tester
Live match highlighting
Every substring your pattern matches is highlighted in the result panel instantly as you type, so you see what the regex catches without running it in code.
Capture & named groups
The match list breaks out each capture group — including named groups written as (?<name>...) — with the exact start position of every match.
All JavaScript flags
Toggle g, i, m, s, u, and y independently and watch results update instantly. Useful for understanding how each flag changes matching behavior.
Regex replace mode
Switch to Replace mode and preview a substitution using $1, $2, or $<name> backreferences before applying it in your editor or code.
How to use Regex Tester
Enter your pattern
Type your regular expression in the Pattern field. Do not include surrounding slashes.
Add flags and test string
Select flags (g for global, i for case-insensitive, m for multiline). Paste the text you want to test against.
See live matches
Matches are highlighted in the test string. Capture groups and match positions are listed below.
Regex syntax cheat sheet — common tokens and what they match
| Token | Matches |
|---|---|
| . | Any character except a line break (any character with the s flag) |
| \d / \D | A digit 0–9 / any non-digit |
| \w / \W | A word character [A-Za-z0-9_] / any non-word character |
| \s / \S | Whitespace (space, tab, newline) / any non-whitespace |
| ^ / $ | Start / end of the string (or line with the m flag) |
| \b | A word boundary — position between \w and \W |
| * / + / ? | 0 or more / 1 or more / 0 or 1 of the preceding token |
| {n} / {n,m} | Exactly n / between n and m repetitions |
| [abc] / [^abc] | Any one of a, b, c / any character except those listed |
| (...) / (?:...) | Capturing group / non-capturing group |
| (?<name>...) | Named capturing group — accessible as match.groups.name |
| a|b | a or b (alternation — tries left side first) |
| (?=...) / (?!...) | Positive / negative lookahead assertion |
| (?<=...) / (?<!...) | Positive / negative lookbehind assertion |
How to fix common syntax errors
Most “invalid JSON” failures come from a small set of mistakes. Paste the failing JSON above, click Validate, and the tool points you at the exact line and column.
/hello.world/The dot matches any character, not a literal dot. Escape it: `/hello\.world/` to match the string "hello.world" exactly.
/\d+/Without the g flag, the regex stops at the first match. Add g to find all matches: `/\d+/g`.
/(foo(bar)/Every opening `(` needs a closing `)`. Count them or use the tool's error message which shows the exact position of the unmatched bracket.
/(a+)+$/ against "aaab"Nested quantifiers on overlapping patterns cause exponential backtracking. Rewrite to atomic or possessive alternatives, or add an anchor to limit the search space.
/^item$/ on multiline textWithout the m flag, ^ and $ match only the start and end of the whole string. Enable the m flag to make them match the start and end of each line.
/Error/ on "error: ..."JavaScript regex is case-sensitive by default. Enable the i flag to match regardless of case, or use a character class like `[Ee]rror`.
Frequently asked questions
A regular expression (regex) is a sequence of characters that defines a pattern for matching, searching, and extracting text. It is used in input validation (email, phone number formats), search-and-replace in code editors, log file parsing, URL routing in web frameworks, and data extraction from unstructured text. Regex is supported natively in almost every programming language.
You might also need
JSON Formatter & Validator
Format, validate, and minify JSON instantly in your browser.
SQL Formatter
Format and beautify SQL queries with consistent indentation and keyword casing.
Base64 Encoder / Decoder
Encode and decode Base64 strings instantly in your browser.
JWT Decoder
Decode and inspect JSON Web Token header, payload, and signature.
Strong Password Generator
Generate cryptographically secure passwords instantly.
Cron Expression Builder
Build cron schedules visually and get the expression + plain-English explanation.
.env File Generator
Generate a boilerplate .env file for Laravel, Next.js, Node.js, or Docker.
.htaccess Generator
Generate Apache .htaccess rules for redirects, HTTPS, caching, and security headers.
Further reading
Authority documentation and specifications behind this tool.
Need this built into your product?
We design and build custom software — SaaS platforms, MVPs, AI agents, and web apps.
Custom SaaS Development
End-to-end SaaS — API, auth, billing, dashboard, deployment.
MVP Development
Working product in 6–8 weeks. Fixed price, committed timeline.
AI Agent Development
Custom AI agents and workflow automation for your stack.
Web App Development
Full-stack web apps built with modern frameworks and best practices.
Have a project in mind?
We turn ideas into production-ready software — SaaS, web apps, mobile, and AI agents. Fixed price. Committed timeline. No surprises.