Regex Tester Online Free
TL;DR — the short answer
To test a regex, paste your pattern into a tester and type test text — every match highlights instantly with its capture groups. The g flag finds all matches, i ignores case, m makes ^/$ work per line. Invalid patterns show the exact error. Try ToolsOfWeb’s free regex tester, which runs 100% in your browser — nothing is uploaded.
Regular expressions fail silently: a pattern that matches nothing gives you no error, just an empty result. A regex tester removes the guesswork by showing every match live as you type — highlighted in your text, broken out by capture group, with JavaScript’s exact error message when the pattern itself is invalid. This guide covers the workflow, the flags, and the debugging routine professionals use.
Try the tool
Open ToolsOfWeb’s Regex Tester for live highlighting, capture groups, flags, and replace preview.
How to test a regex (step-by-step)
- Open the regex tester and type your pattern between the slashes.
- Paste your test text — matches highlight yellow instantly.
- Toggle flags (start with
g) and watch the match list update. - Check the match list for capture-group values and positions.
- Flip to Replace mode to preview substitutions before using them in code.
Example: (\w+)@(\w+\.\w+) against Contact hello@toolsofweb.com finds one match with group 1 = hello and group 2 = toolsofweb.com.
Flags, explained with examples
Flags change what “match” means. /cat/g finds every cat; without g it stops at the first. /cat/i also matches CAT and Cat. /^\d+$/m matches lines that are entirely digits inside multi-line text — without m, ^ and $ only match the very start and end of the whole string. s is the fix when .* mysteriously stops at line breaks: it lets . match newlines too. u matters for emoji and non-Latin scripts; y (sticky) is a niche tool for parsers that match position by position.
Debugging: when your regex matches nothing
Work through this checklist in order: 1. Is the pattern itself valid? An unclosed [ or ( is the #1 cause — the tester shows the exact error. 2. Did you forget the g flag and only see the first match? 3. Are ^/$ anchors too strict? Try removing them. 4. Is case the issue? Try i. 5. Test against the simplest input that should match, then grow the test text until it breaks — the break point is your bug.
Capture groups and replace, in practice
Groups are regex’s real power tool. To reformat 2026-10-05 into 05/10/2026, match (\d4)-(\d2)-(\d2) and replace with $3/$2/$1. To swap emails around, (\w+)@(\w+) → $2@$1. Preview every replacement in the tester first: back-reference mistakes are silent, and seeing the result before it touches your code saves real debugging time.
Helpful follow-up tools
- Normalize matched text with the Text Cleaner.
- Compare pattern versions with the Text Diff Checker.
- Validate the JSON your regex extracts with the JSON Formatter.
FAQs
How do I test a regular expression online?+
Paste your pattern into a regex tester, type or paste test text, and every match highlights instantly. ToolsOfWeb’s free tester shows matches with capture groups, flag toggles, and a replace preview — all in your browser.
What is the difference between the g, i, m, s, u, y flags?+
g finds all matches instead of the first; i ignores case; m makes ^ and $ match line boundaries; s lets . match newlines; u enables Unicode mode; y (sticky) matches only from the current position. Toggle them in a tester to see the difference live.
How do I debug a regex that matches nothing?+
Check the three usual suspects: an unclosed bracket or parenthesis (the tester shows the exact error), a missing flag (often g), and anchors — ^ and $ require the whole string to match. Test against the simplest possible input first, then add complexity.
How do capture groups and back-references work?+
Parentheses create groups numbered left to right: (\w+)@(\w+) captures the username as $1 and the domain as $2. In a replacement string, $1 and $2 reinsert what each group matched — perfect for reformatting text.
Is my regex pattern sent to a server?+
With a client-side tester, no. ToolsOfWeb’s regex tester runs JavaScript’s built-in RegExp engine in your browser — patterns and test text never leave your device.
Test your regex now
Use Regex Tester — free, private, and instant. Live highlighting, capture groups, flags, and replace preview.
