Regex Tester
Regular expressions are powerful and famously easy to get subtly wrong. This free regex tester gives you instant visual feedback: type a pattern, paste test text, and watch matches highlight live — with match counts, positions, and capture groups broken out. It runs on JavaScript's RegExp engine, entirely in your browser, so nothing is ever uploaded.
Highlighted matches
100% client-side — your data never leaves this browser.
What regex is
A regular expression is a miniature language for describing text patterns: \d+ means "one or more digits", ^[a-z]+$ means "a whole string of lowercase letters". They're the right tool for validation (is this an email-shaped string?), extraction (pull all dates from logs), and search-and-replace with structure. They're the wrong tool for nested or recursive formats — the old joke goes: if you try to parse HTML with regex, now you have two problems. Use a real parser for HTML, JSON, and XML.
Common use cases
- Input validation — email, phone, postal-code, and username shapes in forms.
- Log mining — extract timestamps, IPs, and error codes from messy log files.
- Refactoring — find-and-replace with capture groups across a codebase.
- Data cleaning — normalize inconsistent formats before import.
- Learning — the fastest way to internalize regex is watching matches highlight as you type.
How to use it
- Type your pattern (or load a preset).
- Toggle flags — most testing wants
gon. - Paste test text, including cases that should not match.
- Read the highlighted matches and the capture-group breakdown; fix and repeat.
Flags explained
| Flag | Name | What changes |
|---|---|---|
g | Global | Find all matches, not just the first |
i | Ignore case | a matches A |
m | Multiline | ^/$ match line starts/ends |
s | Dot-all | . also matches newlines |
u | Unicode | Full Unicode semantics; enables \p{...} |
Capture groups & common patterns
Parentheses do double duty: they group ((ab)+) and they capture — each group's match is reported separately, which is how you extract the parts. (?<year>\d{4})-(\d{2}) captures the year twice: once as named group year, once as group 1. The presets above are pragmatic starting points with honest limits: the email pattern rejects malformed addresses but also some technically-valid oddities (quoted local parts); the IPv4 pattern matches the dotted shape but doesn't validate 0–255 ranges (use (25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d) per octet if ranges matter). Prefer a stricter pattern only when the strictness buys you something real.
Regex flavors differ
This is the trap that wastes the most hours: a pattern tuned in one engine silently misbehaves in another. JavaScript, Python (re), PCRE (PHP), Go (regexp/RE2), and Java each support a different feature set — lookbehind exists in modern JS but not in older engines; Go's RE2 deliberately omits backreferences for linear-time guarantees; Python's verbose mode has no JS equivalent. Rule of thumb: develop and test in the engine you'll deploy. If this tester (JavaScript) is your target runtime, you're in the right place; if you're shipping Python, treat matches here as a draft, not a proof.
Performance pitfalls
Most regexes run in linear time, but nested quantifiers — (a+)+$, (.*)* — can send the backtracking engine into exponential blowup on inputs that don't match. Attackers know this (it's called ReDoS), and accidents happen too: one greedy group in a log-parsing pattern can hang a tab. Defenses: make quantifiers specific ([^"]* instead of .*), avoid quantifying a group that already contains a quantifier, and test every pattern against a long non-matching string before it goes near production.
Frequently asked questions
- What is a regex tester?
- A tool that runs your regular expression against sample text and shows you exactly what matches — highlighted in place, with match positions and captured groups listed. It turns the write-run-tweak loop of regex development into instant visual feedback.
- Which regex flavor does this tool use?
- JavaScript's RegExp engine — the same one that runs in browsers and Node.js. That covers lookaheads, lookbehinds, named groups, and Unicode property escapes, but not engine-specific features like PCRE recursion or atomic groups. Always test in the engine you'll ship.
- Why doesn't my Python pattern work here?
- Regex flavors differ more than people expect. Python's (?P<name>...) named groups, verbose mode (?x), and some inline-flag placements have different syntax (or no equivalent) in JavaScript. Translate the construct rather than pasting blindly — the syntax error message usually points at the culprit.
- What do the flags do?
- g finds all matches instead of stopping at the first; i ignores letter case; m makes ^ and $ match line boundaries instead of string boundaries; s lets . match newlines too; u enables full Unicode mode (needed for \p{...} property escapes and correct handling of emoji).
- How do I match an email address?
- Use the Email preset as a starting point — but know its limits. A fully RFC-compliant email regex is thousands of characters long and still not recommended; in practice, validate with a pragmatic pattern and then confirm by sending an actual email. The preset catches typos, not every edge case.
- Is my test data uploaded anywhere?
- No. Matching runs entirely in your browser with the native RegExp engine. Patterns and test strings never leave your device — safe for sensitive log snippets.
- Why did my pattern freeze the tab?
- Almost certainly catastrophic backtracking: nested quantifiers like (a+)+$ make the engine try an exponential number of combinations on non-matching input. Rewrite with atomic-like structure (e.g., possessive quantifiers where supported, or a more specific character class) and test against adversarial input.