Free Online Regex Tester — Live JavaScript Regular Expressions
Test JavaScript regular expressions with live highlighting, capture groups, flags, and find-and-replace. Common patterns included.
Match details
| # | Match | Index | Groups |
|---|---|---|---|
| 1 | jane.doe@example.com | 9 | — |
| 2 | support@kaviforge.com | 31 | — |
Quick answer
To test a regular expression, type the pattern into the KaviForge Regex Tester, choose flags (g, i, m, s, u, y), and paste your test text. Matches are highlighted instantly, and a table lists each match with its index and capture groups. Enter a replacement to preview String.replace results.
Test JavaScript regular expressions as you type. See live matches, capture groups, flags, and replacements — plus built-in patterns for email, URL, and more.
This tester uses your browser’s native JavaScript RegExp engine, so results match exactly what Node.js, React, and browser code will do, including named groups, lookbehind, and Unicode mode.
How to Test a Regex
- 1Enter your pattern between the slashes, or pick one from "Common patterns".
- 2Toggle flags such as g (global), i (ignore case), or m (multiline).
- 3Paste or type your test string.
- 4Review highlighted matches and the match details table with groups.
- 5Optionally enter a replacement (using $1 or $<name>) to preview the replaced text.
Features
Live Match Highlighting
Every match is highlighted as you type the pattern or text.
Capture & Named Groups
See numbered groups ($1, $2…) and named groups for each match.
All JavaScript Flags
g, i, m, s (dotAll), u (unicode), and y (sticky).
Find & Replace Preview
Test replacements with $1, $<name>, and $& backreferences.
Common Patterns Library
Email, URL, IPv4, date, hex color, phone, and more to start from.
Clear Error Messages
Invalid patterns show the exact JavaScript syntax error.
When to Use the Regex Tester
Validate form input
Build and test patterns for emails, phone numbers, postcodes, and usernames.
Extract data from logs
Pull IPs, timestamps, or error codes out of log lines with capture groups.
Search and replace in code
Preview complex replacements before running them in your editor or script.
Learn regex
Experiment with flags and groups and see results immediately.
About the Regex Tester
Patterns are compiled with new RegExp(pattern, flags) in your browser. Global and sticky searches iterate with exec and safely handle zero-length matches. Up to 1,000 matches are collected.
Very complex patterns with nested quantifiers can cause catastrophic backtracking on long inputs. If the page slows down, simplify the pattern or shorten the test text.
Regex Tester FAQs
How do I test a regular expression online?
Enter your pattern and test text in the KaviForge Regex Tester. Matches are highlighted instantly and listed in a table with their capture groups.
Which regex flavor does this tester use?
JavaScript (ECMAScript) regular expressions, using your browser’s built-in RegExp engine — the same one used by Node.js and all modern browsers.
What do the g, i, m, and s flags do?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at line breaks, and s lets . match newline characters.
How do I use named capture groups?
Write (?<name>pattern). The match table shows each named group, and you can reference it in replacements as $<name>.
How do I test a regex replacement?
Type the replacement text in the "Replace with" box. Use $1 for the first group, $<name> for named groups, and $& for the whole match.
Is my test data private?
Yes. Matching runs entirely in your browser.
Popular Regex Tester searches
- Regex for Email ValidationA practical regex for email validation with test cases. Try the pattern against valid and invalid addresses and learn why perfect email regex does not exist.
- Regex for Phone NumbersTest a regex for phone numbers that accepts common US and international formats such as +1 555-123-4567. Try your own examples live.
- Regex for URL ValidationTest a regex that matches http and https URLs. Check it against valid and invalid links and learn when to use the URL constructor instead.
- Regex for an IPv4 AddressA tested regex for IPv4 addresses that limits each octet to 0–255. Try it on valid and invalid IPs such as 192.168.1.1 and 256.1.1.1.
- Regex for a YYYY-MM-DD DateRegex to match dates in YYYY-MM-DD format, restricting months to 01–12 and days to 01–31. Test it against valid and invalid dates.
- Regex for Hex Color CodesRegex that matches CSS hex colors like #fff and #1a2b3c. Try valid and invalid values and learn how to extend it for alpha channels.
- Regex for Password StrengthRegex that requires lowercase, uppercase, a digit and at least 8 characters, using lookaheads. Test passwords live and see why length matters most.
- Regex for Username ValidationA username regex allowing letters, numbers and underscores with 3–16 characters. Test valid and invalid names and adapt the rules to your app.
- Regex to Extract Numbers From a StringExtract all numbers from text with the global regex \d+. See the matches, then extend the pattern for decimals and negative numbers.
- Regex for US ZIP CodesRegex that matches US ZIP codes in 5-digit and ZIP+4 formats. Test valid and invalid values like 90210 and 90210-1234.
Related Developer Tools
JSON Formatter & Validator
Pretty print, beautify, minify, and validate JSON online free. Tree view, file upload, private browser-only.
URL Decoder
Decode percent-encoded URLs and query strings, and see every query parameter in a table.
Cron Expression Generator
Build and explain cron expressions in plain English and preview the next run times.