Test, debug, and validate regular expressions online with live match highlighting, capture group details, and real-time error feedback. Supports all JavaScript regex flags — no sign-up required.
A regex tester (regular expression tester) is an online tool that lets you write, test, and debug regex patterns against sample text in real time. Regular expressions — shortened to regex or regexp — are sequences of characters that define a search pattern. They are used by virtually every programming language and developer tool for string matching, validation, extraction, and find-and-replace operations.
Writing a correct regular expression without a tester is notoriously error-prone. A single misplaced quantifier, forgotten escape character, or wrong flag can cause a pattern to match nothing, match too much, or behave differently across languages. Our online regex tester provides instant visual feedback — highlighting every match in the test string, showing exact character positions, and displaying all capture groups and named groups — so you can iterate and fix patterns interactively rather than guessing.
This tool runs entirely in your browser using the JavaScript regex engine (ECMAScript standard), which means your test strings and patterns are never sent to any server.
/pattern/) — enter the pattern only.Regex flags modify how the pattern engine processes your expression. This tool supports all six standard JavaScript flags:
Find all matches in the string, not just the first one. Without this flag, the engine stops at the first match. Essential for extracting all occurrences of a pattern from a block of text.
Makes matching case-insensitive. The pattern [a-z] will also match A-Z. Use for email validation, keyword matching, and any search where case differences are irrelevant.
Changes the behavior of ^ and $ anchors. Without this flag, ^ and $ match the start and end of the entire string. With m, they match the start and end of each individual line.
Makes the . metacharacter match every character including newline characters (\n). Without this flag, . does not match newlines, which can cause surprises with multi-line strings.
Enables full Unicode support. Required for correctly matching Unicode code points above U+FFFF (like emoji), Unicode property escapes (\p{Letter}), and proper surrogate pair handling.
Only matches starting at the exact position of lastIndex — it does not search ahead in the string. Useful for incremental tokenization and parsing, where you process a string position-by-position.
| Pattern | Meaning | Example |
|---|---|---|
| . | Match any character except newline | . → matches a, 1, @ |
| \d | Match any digit (0–9) | \d+ → matches 123 |
| \w | Match word character (a-z, A-Z, 0-9, _) | \w+ → matches hello_1 |
| \s | Match whitespace (space, tab, newline) | \s+ → matches spaces |
| ^ | Start of string (or line with m flag) | ^Hello → only at start |
| $ | End of string (or line with m flag) | world$ → only at end |
| * | Zero or more of preceding | ab* → a, ab, abb |
| + | One or more of preceding | ab+ → ab, abb (not a) |
| ? | Zero or one of preceding (optional) | colou?r → color, colour |
| {n,m} | Between n and m repetitions | \d{2,4} → 12, 123, 1234 |
| [abc] | Match any character in set | [aeiou] → vowels |
| [^abc] | Match any character NOT in set | [^0-9] → non-digits |
| (abc) | Capture group | (\d+) → captures digits |
| (?<name>) | Named capture group | (?<year>\d{4}) |
| (?:abc) | Non-capturing group | (?:https?) → no capture |
| a|b | Match a or b | cat|dog → cat or dog |
| \b | Word boundary | \bword\b → exact word |
| (?=abc) | Positive lookahead | \d(?= px) → digit before px |
| (?!abc) | Negative lookahead | \d(?! px) → digit NOT before px |
Copy any of these production-ready patterns into the tester above:
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\bhttps?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])\b#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b<\/?[a-z][a-z0-9]*(?:\s[^>]*)?>^(?=.*[A-Z])(?=.*\d)[A-Za-z\d@$!%*?&]{8,}$^[a-z0-9]+(?:-[a-z0-9]+)*$^[6-9]\d{9}$Validate form inputs (email, phone, password, ZIP code), parse URL parameters, sanitize user-submitted text, and write routing rules in web frameworks like Express, Django, and Rails.
Extract structured fields from raw log files, clean messy CSV data, parse server access logs, find patterns in large datasets, and write ETL transformation rules in Python (re module), SQL, or Spark.
Use regex in Google Search Console and Google Analytics to filter branded vs. non-branded queries, segment URL patterns, isolate informational vs. transactional keywords, and automate redirect mapping.
Parse application logs for error patterns, write Nginx/Apache rewrite rules, filter systemd journal output with grep, configure monitoring alert rules, and extract metrics from log streams.
Write test assertions that match dynamic output, validate API response formats, create test fixtures with pattern-based data generation, and build automated input validation test cases.
Use find-and-replace in VS Code, Sublime Text, or Notepad++ with regex to bulk-reformat content, fix inconsistent punctuation, or extract specific data from exported CMS content.
A regular expression is a sequence of characters that defines a search pattern. It is a formal language for pattern matching within strings. Regex patterns can describe simple things (a specific word) or complex structures (all valid email addresses, all IPv4 addresses). They are supported in JavaScript, Python, Java, PHP, Go, Rust, C#, Ruby, and essentially every modern programming language.
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. It supports all standard metacharacters, lookaheads, lookbehinds (ES2018+), named capture groups, Unicode property escapes (with the u flag), and all six flags (g, i, m, s, u, y). Note that JavaScript regex differs slightly from PCRE (PHP, Python) and .NET regex — particularly in some advanced features.
Capture groups are portions of a regex enclosed in parentheses (). They capture the text matched by that part of the pattern for later use. For example, in (\d{4})-(\d{2})-(\d{2}), group 1 captures the year, group 2 the month, group 3 the day. Named capture groups use the syntax (?<name>pattern) and are accessible by name. The tool displays all captured groups for every match.
Greedy quantifiers (*, +, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. For example, in the HTML <b>bold</b><i>italic</i>, the pattern <.+> greedily matches the entire string, while <.+?> lazily matches each individual tag. Use lazy quantifiers when you need to match the shortest possible string.
This usually happens because: (1) you're missing anchors — add ^ at the start and $ at the end for exact matching; (2) you're using a greedy quantifier when a lazy one is needed; (3) your character class is too broad; or (4) the g (global) flag is finding additional partial matches you didn't anticipate. The live highlighting in this tool makes it easy to spot unintended matches.
Click the Sample button to load a pre-built email regex with test strings. The standard email validation pattern is \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b. Enable the g flag to find all emails in a block of text and the i flag for case-insensitive matching. Note that a 100% accurate email regex is extremely complex; for production use, combine a simple regex with server-side confirmation email.
This tool uses the JavaScript (ECMAScript) regex engine. Most standard patterns work identically across JavaScript, Python, PHP, Java, and Go. However, there are differences: Python uses (?P<name>) for named groups (JavaScript uses (?<name>)), .NET supports possessive quantifiers and atomic groups (JavaScript doesn't), and PCRE supports some extended features not in JavaScript. For JavaScript-specific applications, this tool is fully accurate.
Discover more free developer tools that might interest you
Convert text between upper, lower, title cases and more
Convert between HTML and Markdown
Generate placeholder text for design and content
Format and validate JSON data
View JSON data in a tree structure
Minify JSON data to reduce size