Regex Tester
Test regular expressions with live match highlighting, capture groups, and replace preview. Supports all JavaScript regex flags.
About This Tool
Debugging a regex like ^(?:[a-z0-9]+(?:\.[a-z0-9]+)*)@(?:[a-z0-9-]+\.)+[a-z]{2,}$ in your head is painful. The Regex Tester gives you real-time match highlighting, numbered and named capture groups, and a live replace preview — so you can see exactly what your pattern matches (and misses) as you type.
The tool runs on your browser's native RegExp engine — the same engine your JavaScript or Node.js code uses — so results are identical to production. All six JavaScript flags are supported: global (g), case-insensitive (i), multiline (m), dotAll (s), unicode (u), and sticky (y).
The Match view shows highlighted matches in context plus a detailed breakdown of each match with its index and capture groups — both numbered and named. The Replace view lets you enter a replacement string (using $1, $2, etc. for back-references) and see the result in real time. The Library view provides a curated collection of common patterns you can load with one click.
All processing stays client-side. Your patterns and test data never leave your browser. Once you've validated your data format, you can process it with the JSON Formatter or encode special characters with the URL Encoder. Need to validate a UUID pattern you just wrote? Test it against sample IDs from the UUID Generator.
How to Use
- Enter a regex pattern in the pattern input. The pattern is shown between forward-slash delimiters.
- Toggle flags by clicking the flag badges (
g,i,m,s,u,y). - Type or paste your test string. Matches are highlighted instantly.
- Review the Matches & Capture Groups section for detailed match info including group values and indices.
- Switch to Replace mode to enter a replacement string and see the transformed output.
- Use the Library to quickly load common patterns like email, URL, IP address, and more.
- Click Copy or press Ctrl+Shift+C to copy the full regex with flags.
FAQ
Which regex engine does this tool use?
This tool uses your browser's built-in JavaScript RegExp engine. Results will match exactly what you'd get running the same regex in Node.js or any modern browser.
What do the flags mean?
g (global) finds all matches, not just the first. i makes matching case-insensitive. m makes ^ and $ match line boundaries. s makes . match newlines. u enables full Unicode matching. y (sticky) matches only at lastIndex.
How do capture groups work?
Parentheses () create capture groups. Each group captures the text matched by the sub-pattern inside. Groups are numbered left-to-right starting at 1. Named groups use the syntax (?<name>...) and appear under their name in the results.
What are back-references in replacement?
In the replacement string, $1, $2, etc. refer to the text captured by the corresponding numbered group. $& refers to the entire match. $` and $' refer to text before and after the match.
Is my data safe?
Yes. Pattern matching runs locally via the browser's built-in JavaScript RegExp constructor — the same API available in any browser DevTools console. No network requests are made, and no data is logged or stored anywhere outside your machine.
Can regex patterns cause the browser to hang?
Certain patterns with nested quantifiers (like (a+)+) can cause catastrophic backtracking on some inputs. If the browser becomes unresponsive, reload the page and simplify your pattern. This tool limits match iterations to prevent infinite loops.
Related Tools
Cron Expression Builder
Build and validate cron expressions with a visual editor and next run times.
JSON Formatter
Format, validate, and beautify JSON with syntax highlighting and tree view.
URL Encode/Decode
Encode and decode URLs, parse query parameters, and build query strings.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes for text and files.
Text Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, and other naming conventions.
Conventional Commits Linter
Validate commit messages against the Conventional Commits specification. Check type, scope, description, and body format.
ICU Message Format Tester
Test and preview ICU MessageFormat patterns with live variable substitution, plural, select, number, and date formatting.
Stack Trace Parser
Parse, format, and analyze stack traces from JavaScript, Python, Java, Go, Ruby, C#, and Rust with auto-detection and frame filtering.
Prompt Token Cost Calculator
Estimate prompt and completion costs across GPT-4o, Claude, Gemini, and DeepSeek with the official OpenAI tokenizer and cache discounts.