Regex Tester
Test regex patterns with live matches.
Example
- In:
- hello
- Out:
- Matches at index 0
Guide
Introduction
Regular expressions power validation, parsing, and search across every codebase — yet they remain notoriously difficult to debug. A email regex rejects valid plus-addresses. A log parser captures the wrong group. A negative lookahead spirals into catastrophic backtracking that hangs your server. Before you commit a pattern to production middleware or paste it into a code review, you need to test it interactively against sample strings and see exactly which groups matched.
Certoflow's Regex Tester evaluates JavaScript-compatible regular expressions entirely in your browser. Enter a pattern, flags, and test strings; view match highlights, capture groups, and index positions instantly. Test data never uploads — customer emails, auth logs, and proprietary URL formats stay on your device.
What this tool does
Interactive regex debugging with immediate feedback:
| Feature | Description |
|---|---|
| Pattern input | Regular expression body (with or without delimiters) |
| Flags | g global, i case-insensitive, m multiline, s dotAll, u unicode, y sticky |
| Test string | Multiline input to match against |
| Match results | Full match, groups, indices, match count for global patterns |
| Replace preview | Substitution output when supported |
| Copy / Clear | Standard toolbar |
Validation catches invalid patterns (unclosed groups, invalid escapes) before execution.
How it works
The tester constructs a JavaScript RegExp object and executes exec or matchAll against input:
const regex = new RegExp(pattern, flags);
const match = regex.exec(testString);
// match[0] — full match
// match[1], match[2] — capture groups
// match.index — start position
Global flag (g) enables iterative matching:
const regex = /(\w+)@(\w+\.\w+)/g;
const matches = [...testString.matchAll(regex)];
Client-side execution means:
- Same semantics as browser JavaScript and Node.js (V8 / similar engines)
- No PCRE, no Python
re, no JavaPattern— dialect differences exist - Instant feedback without server latency
Example pattern for ISO dates:
\b(\d{4})-(\d{2})-(\d{2})\b
Test string:
Events on 2024-06-15 and 2024-12-01 confirmed.
Groups capture year, month, day separately for transformation pipelines.
Common flag combinations
| Flags | Effect |
|---|---|
i | Hello matches hello |
m | ^ and $ match line boundaries |
s | . matches newline characters |
g | Find all matches, not just first |
u | Unicode code point mode (\u{1F600}) |
Real-world examples
Email validation sanity check
Pattern (simplified — not production-complete):
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Test: user+tag@example.co.uk → match. Test: invalid@@example.com → no match. Verify before embedding in form validator.
Extracting log fields
Apache combined log format — extract IP and path:
^(\S+) \S+ \S+ \[([^\]]+)\] "(\S+) (\S+) \S+" (\d+)
Paste sample log line; confirm group 1 is IP, group 4 is path, group 5 is status code.
Password policy enforcement
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Test weak passwords fail; strong password passes — debug lookahead separately if pattern fails unexpectedly.
URL path parameter extraction
/users/(\d+)/posts/(\d+)
Against /users/42/posts/99/edit — confirm greedy vs non-greedy behavior for nested paths.
Markdown link parsing
\[([^\]]+)\]\(([^)]+)\)
Extract link text and href from [Certoflow](https://certoflow.example) for custom renderer prototyping.
Unicode emoji matching
With u flag:
\p{Emoji_Presentation}
Test against Hello 👋 World — verify engine supports Unicode property escapes (ES2018+).
Common mistakes
Assuming regex tested here works identically in Python/Java. Character classes, lookahead, and word boundaries differ. Test in target runtime or document engine-specific behavior.
Catastrophic backtracking. Patterns like (a+)+$ against long strings of a with trailing mismatch cause exponential time. Keep quantifiers bounded; use atomic groups or possessive quantifiers where engine supports.
Over-validating emails and URLs with regex alone. RFC-compliant email regex is enormous. Use library validation for production; regex tester for prototyping subsets.
Forgetting to escape special characters. Literal . matches any character — use \. for dots. Literal $ in prices needs \$ or [.].
Global regex statefulness. JavaScript RegExp with g maintains lastIndex. Reusing same object across tests may skip matches — create fresh instances in application code.
Missing multiline flag. ^ matches string start only without m. Line-by-line validation needs m.
Trusting client-side regex for security. Attackers bypass browser validation. Re-validate server-side always.
Greedy vs lazy quantifiers. .* consumes maximum; .*? minimum. URL parsing often needs lazy: https://(.*?)/ vs greedy eating too much.
Use cases
Frontend developers crafting input masks, search filters, and syntax highlighting token patterns.
Backend developers debugging middleware path matchers, log parsers, and data extraction ETL rules.
QA engineers building test case strings that should pass/fail validation before automation suite updates.
Technical writers documenting regex examples with verified match output screenshots from local testing.
Students learning capture groups, alternation, and character classes with immediate visual feedback.
DevOps engineers testing grok patterns conceptually before translating to Logstash or Elasticsearch ingest pipelines — noting syntax translation required.
FAQ
Is my test data sent to a server?
No. Regex execution runs entirely in your browser via JavaScript.
Which regex flavor does this use?
JavaScript (ECMAScript). Node.js uses the same engine family; Python, Java, and Go differ.
Why does my valid PCRE pattern fail?
Lookbehind support, \Z anchors, and named group syntax vary. Adapt pattern to JavaScript rules.
Can I test replace operations?
When supported, enter replacement string with $1, $2 group references and preview output.
What causes "Invalid regular expression"?
Unclosed (, [, invalid escape sequences, or malformed quantifiers {.
Does the tester detect ReDoS?
Generally no — avoid testing extremely long strings against risky patterns locally; browser tab may freeze.
How do I match literal backslashes?
Escape as \\ in JavaScript regex strings — four backslashes in some JSON contexts.
Can I save patterns?
Use copy to clipboard and version control. No account storage required — patterns stay in your workflow tools.
What's the difference between match and exec?
exec returns one match object with groups; global iteration uses repeated exec or matchAll.
Can I use this offline?
Yes, after initial page load.
Frequently Asked Questions
- Which regex flavor?
- JavaScript RegExp (ECMAScript). Flags g, i, m, s, u, y are supported per browser.
- Are patterns sent to a server?
- No. Matching runs locally in your browser.
Related Tools
Continue with these related utilities.
JSON Validator
Check if JSON is valid with clear errors.
Developer ToolsURL Encoder
Encode text for URL query parameters.
Developer ToolsHTML Formatter
Indent and format HTML markup.
Developer ToolsJavaScript Minifier
Compress JavaScript snippets locally.
Developer ToolsHex Converter
Convert text, hex, and decimal in both directions.