Regex Tester
Test regular expressions with live matching, capture groups, and flag support.
Test regular expressions with live matching, capture groups, and flag support.
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to match, find, and manipulate text strings. Regex is supported in virtually every programming language, text editor, and command-line tool.
Regular expressions range from simple literal matches like "hello" to complex patterns that can validate email addresses, extract data from logs, or transform entire documents. They are one of the most powerful tools in a developer's toolkit for working with text.
Some patterns come up repeatedly in real-world development. Email validation typically uses a pattern like [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} to match standard email formats. URL matching looks for the http or https protocol followed by a domain and path.
Phone number patterns vary by region but generally match sequences of digits separated by common delimiters like dashes, dots, or spaces. IP address patterns match four groups of one to three digits separated by dots. Date patterns depend on the expected format, with YYYY-MM-DD being one of the most common in technical contexts.
Flags modify how the regex engine processes your pattern. The global flag (g) tells the engine to find all matches in the string rather than stopping after the first one. Without it, only the first match is returned.
The case-insensitive flag (i) makes the pattern match regardless of letter case, so /hello/i matches "Hello", "HELLO", and "hello". The multiline flag (m) changes how ^ and $ anchors work, making them match the start and end of each line instead of just the start and end of the entire string. The dotAll flag (s) makes the dot character match newline characters as well. The unicode flag (u) enables full Unicode matching, which is important when working with emoji or non-Latin scripts.
Poorly written regex patterns can be extremely slow, especially on large strings. Avoid nested quantifiers like (a+)+ which can cause catastrophic backtracking where the engine tries an exponential number of paths before failing.
Be as specific as possible with your patterns. Use character classes like [0-9] instead of .* when you know what characters to expect. Use non-capturing groups (?:...) instead of capturing groups (...) when you do not need to extract the matched content. Anchor your patterns with ^ and $ when you know the match should be at the start or end of the string, which helps the engine fail faster on non-matching input.
This tool runs entirely in your browser using JavaScript's built-in RegExp engine. Your pattern and test string never leave your device. As you type, the tool compiles your pattern into a regex object, executes it against the test string, and displays all matches with highlighting, index positions, and capture groups in real time.
This tester supports the full JavaScript regular expression syntax, including character classes, quantifiers, lookahead and lookbehind assertions, named capture groups, backreferences, and all standard flags (g, i, m, s, u). If your browser supports it, the regex will work here.
Capture groups are portions of a pattern enclosed in parentheses. They let you extract specific parts of a match. For example, the pattern (\d{4})-(\d{2})-(\d{2}) applied to the string 2024-03-15 creates three capture groups for the year, month, and day. Named capture groups use the syntax (?<name>...) and appear with their names in the results table.
The most common causes of regex errors are unescaped special characters, unmatched parentheses or brackets, invalid quantifier ranges (like {5,2}), and incomplete escape sequences. The error message shown below the pattern field tells you exactly what the JavaScript regex engine rejected. Double-check that special characters like (, ), [, ], {, }, and \ are properly escaped or paired.
Yes. All regex processing happens entirely in your browser using client-side JavaScript. Your patterns and test strings are never sent to any server. No data is stored, logged, or transmitted. You can verify this by checking your browser's network tab while using the tool.