Regex Tester
Write and test regular expressions against any text. See matches highlighted in real time, inspect capture groups, and debug your patterns instantly.
Invalid regular expression
0 matches found
You might also need.
Search and replace text in any document with plain text or regex patterns.
Format, minify, and validate JSON instantly in the browser.
Encode plain text to Base64 or decode Base64 strings back to plain text instantly.
Compare two blocks of text side by side and see added, removed, and unchanged lines.
Strip extra spaces, tabs, and blank lines from any block of text instantly.
Remove repeated lines from any block of text with one click.
About the Regex Tester
A Regex Tester is an essential tool for developers, data analysts, and QA engineers who work with text patterns. Regular expressions (regex) are concise pattern-matching mini-languages built into nearly every programming language and text editor. This browser-based tester runs entirely on the JavaScript ECMAScript RegExp engine — which means patterns execute instantly in your browser without any server round trips, and your test data is never transmitted anywhere.
As you type, every match is highlighted directly inside the preview area and listed below with its character index, full match text, and any numbered or named capture groups. This real-time feedback loop dramatically speeds up the iteration cycle when debugging complex expressions.
Who uses a Regex Tester?
- Front-end & back-end developers — validate user-input formats (email, phone numbers, ZIP codes, credit card numbers) before submitting forms to a server.
- Data engineers & analysts — parse structured log files, extract metrics from raw server output, and clean large datasets by identifying malformed records.
- DevOps & SRE teams — write patterns that filter log streams, configure alerting rules, and build ingestion pipelines in tools like Splunk, Elasticsearch, or CloudWatch.
- Security researchers — build patterns to detect injection attempts, audit input sanitization logic, and write WAF rules.
- Content editors & technical writers — find and bulk-replace specific text patterns across documents without opening a full IDE.
- QA engineers — write test assertions that check API responses, HTML output, and log lines against expected patterns.
Supported regex syntax
The tool uses the JavaScript RegExp engine (ECMAScript 2022+). This covers the vast majority of patterns you would write in any PCRE-compatible language. Below is a quick reference for commonly used constructs:
| Pattern | Meaning |
|---|---|
| \d | Any digit (0–9) |
| \w | Word character (letter, digit, underscore) |
| \s | Any whitespace character (space, tab, newline) |
| . | Any character except newline (use s flag to include newlines) |
| ^ $ | Start / end of string (or line with m flag) |
| * + ? | Zero-or-more / one-or-more / zero-or-one (greedy) |
| {n,m} | Between n and m repetitions |
| [abc] | Character class — matches a, b, or c |
| [^abc] | Negated class — matches any character except a, b, c |
| (...) | Capturing group — result visible in the Matches panel |
| (?:...) | Non-capturing group — groups without creating a back-reference |
| (?<name>...) | Named capture group — accessible as match.groups.name |
| (?=...) (?!...) | Positive / negative lookahead |
| (?<=...) (?<!...) | Positive / negative lookbehind |
| a|b | Alternation — matches a or b |
| \b | Word boundary — position between a word and a non-word character |
Available flags
Flags modify how the pattern engine interprets matches. Toggle them using the letter buttons next to the pattern input:
Find all matches in the string. Without this flag, only the first match is returned.
Match letters regardless of case. /hello/i matches "Hello", "HELLO", and "hello".
^ and $ match the start/end of each line rather than the entire string.
The . metacharacter matches newline characters (\n) as well. Useful for multi-line content.
Enables full Unicode mode. Required for \p{...} Unicode property escapes and correct emoji handling.
Common regex use cases
Email address validation
[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}ISO 8601 date extraction (YYYY-MM-DD)
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])IPv4 address matching
(?:\d{1,3}\.){3}\d{1,3}Extracting HTML tag content (non-greedy)
<(\w+)[^>]*>(.*?)<\/\1>US phone number (with named groups)
(?<area>\d{3})[.\-\s]?(?<exchange>\d{3})[.\-\s]?(?<line>\d{4})Tips for writing better regex
- Be as specific as possible. Overly broad patterns (like
.*) can match far more than intended and may cause catastrophic backtracking on large inputs. - Use non-greedy quantifiers (
*?,+?) when you want the shortest possible match between two anchors. - Anchor your patterns with
^and$(or\b) whenever you're validating a complete string rather than searching within a larger one. - Name your capture groups with
(?<name>...)for patterns with multiple groups — it makes the match output self-documenting and far easier to maintain. - Enable the
uflag when working with emoji, CJK characters, or any non-ASCII content to ensure correct Unicode code-point handling. - Test edge cases — empty strings, strings with only whitespace, strings that almost match, and strings that should not match at all.