Regex Tester
Write and test regex patterns with sample input, flags, matches, groups, and replace.
Regex Tester
JavaScript (ECMAScript) regular expressions.
Max processed: 100,000 characters. Matches capped at 1,000.
Use $1, $2… for numbered groups, $& full match, $<name> for named groups.
Replace Output
(enter a replacement)
Highlighted Match
Matches & Groups
#1 [0 to 0):
Positional Groups
- none
Named Groups
- none
Matches (JSON)
[
{
"match": "",
"index": 0,
"groups": {},
"captures": []
}
]What is a Regex Tester?
A regex tester is a tool for writing, testing, and debugging regular expressions: powerful pattern-matching syntax used in virtually every programming language. Regular expressions can validate email addresses, extract data from strings, find and replace text, parse log files, and much more. However, regex syntax is notoriously difficult to write correctly without instant feedback.
CodeHelper's Regex Tester highlights matches in real time, shows named groups, tests replacements, and includes a full cheat sheet and pattern library so you can write correct regex faster.
Key Features
- Real-time Match Highlighting: Matches are highlighted in the test string as you type your pattern.
- Capture Groups & Named Groups: View all captured groups and their values for complex extraction patterns.
- Replace Preview: Test your
.replace()pattern with a replacement string to verify the output. - Flags Support: Toggle global (g), case-insensitive (i), multiline (m), dotAll (s), and unicode (u) flags.
- Pattern Library: A built-in library of common patterns: email, URL, IP address, date, phone number, and more.
- Regex Cheat Sheet: Quick reference for metacharacters, quantifiers, anchors, and assertions.
How to test a regular expression
- Enter your regex pattern in the pattern field.
- Paste or type your test string in the input area.
- Matches are highlighted automatically in real time.
- Review groups and captured values in the results panel.
- Use the replace tab to test substitutions, then generate code for your language.
Whether you are validating form inputs in JavaScript, parsing log files in Python, or writing complex search patterns for a text editor, this free online regex tester is the fastest way to get your pattern right.
Regex cheat sheet: the patterns everyone looks up
| Pattern | Matches |
|---|---|
. | Any single character except newline |
\d / \w / \s | Digit / word character / whitespace |
^ / $ | Start / end of string (or line with the m flag) |
* / + / ? | 0 or more / 1 or more / 0 or 1 of the previous token |
{2,5} | Between 2 and 5 repetitions |
[abc] / [^abc] | Any of a, b, c / anything except them |
(x|y) | x or y, captured as a group |
(?=...) / (?!...) | Lookahead: followed by / not followed by |
^[^@\s]+@[^@\s]+\.[^@\s]+$ | Practical email shape check |
^https?:\/\/[^\s]+$ | Simple URL check |
Frequently Asked Questions
What is a regex (regular expression)?
A regex is a compact pattern language for matching text: instead of searching for an exact string, you describe the shape of what you want (digits, repetitions, alternatives, positions) and the engine finds everything that fits. Regexes power validation, search and replace, log parsing and lexers in virtually every language and editor.
Does this tester use JavaScript regex syntax? How is it different from Python or PCRE?
Yes, patterns run on the JavaScript engine of your browser. The core syntax is shared across JavaScript, Python and PCRE, and most patterns port unchanged. The classic differences: named group syntax, lookbehind support in older environments, and Python-only verbose mode. If a pattern is destined for another language, keep to the shared core and test the edge cases there.
What is the best regex to validate an email address?
A pragmatic shape check like ^[^@\s]+@[^@\s]+\.[^@\s]+$ catches typos without rejecting valid addresses. The fully RFC-compliant email regex is famously enormous and still cannot tell you if the mailbox exists, so real validation is a confirmation email; the regex is just the first filter.
Why is my regex matching too much (greedy matching)?
Quantifiers are greedy by default: .* grabs as much as possible while still allowing a match. Add a ? to make them lazy (.*? stops as early as possible), or better, replace the dot with a negated class like [^"]* which cannot cross the delimiter. The live highlighting here makes the difference visible immediately.
Related
Free forever, no ads, no tracking. Support the project