Testing regular expression...
Enter a pattern and test text to inspect matches, capture groups, and replacement output.
How to Use the RegEx Tester & Debugger
This RegEx Tester & Debugger executes regular expressions with Go's RE2-compatible engine. Enter a pattern without surrounding slash delimiters, paste the text you want to search, choose any flags, and select whether to find every match or only the first. The result highlights matches and reports precise byte, character, line, and column positions.
Use capture groups when you need specific pieces of each match. A numbered group such as (\d+) appears as Group 1. A named group such as (?P<year>\d{4}) is easier to identify in complex patterns. Enable replacement preview to test Go replacement references such as $1 and ${name}.
How Regular Expression Matching Works
A regular expression describes a text pattern. Literal characters match themselves, character classes select groups of allowed characters, quantifiers control repetition, and anchors restrict where a match may begin or end.
Matching is performed against exact UTF-8 text. Whitespace is not trimmed or normalized. Byte offsets can differ from character offsets when text contains Unicode characters, so this debugger reports both values.
Zero-width patterns such as word boundaries match positions rather than visible characters. They are shown as narrow markers so the original text remains unchanged.
Go RE2 vs JavaScript, Python, and PCRE
Regex syntax is not identical across programming languages. This tool always executes matches with Go/RE2. The JavaScript, Python, and PCRE profiles provide compatibility guidance; they do not run those engines.
RE2 deliberately excludes constructs such as lookaround and backreference matching. This design guarantees linear-time matching and avoids catastrophic backtracking, making it a predictable engine for a public regex testing service.
If a pattern works in another language but fails here, inspect the compatibility notes and replace engine-specific syntax with an RE2-compatible approach.
Regular Expression Syntax Reference
| Syntax | Meaning | RE2 |
|---|---|---|
| . | Any character except newline unless s is active | Yes |
| ^ $ | Start and end anchors | Yes |
| \d \w \s | Common character classes | Yes |
| * + ? {n,m} | Repetition quantifiers | Yes |
| (...) / (?:...) | Capturing and non-capturing groups | Yes |
| (?P<name>...) | Named capturing group | Yes |
| (?=...) / (?<=...) | Lookahead and lookbehind | No |
| \1 | Backreference matching | No |
Regex Flags, Captures, and Replacement
What do regex flags change?
i ignores letter case, m makes anchors work per line, s lets the dot match newlines, and U makes quantifiers ungreedy by default.
How does regex replacement work?
Replacement output combines literal replacement text with captured values. Go supports numbered references such as $1 and named references such as ${name}. Replacement syntax differs between engines.
Why did an optional group not participate?
An optional capture may be absent even when the full expression matches. That differs from an empty participating capture, which matched a valid zero-character value.
How do I debug a complex regex?
Start with a small representative text sample. Test one section at a time, inspect capture groups, then add anchors and quantifiers gradually. Prefer clear patterns over compressed expressions that are difficult to maintain.
Frequently Asked Questions
How do I test a regular expression online?
Enter the pattern without slash delimiters, add representative test text, select the required flags, and submit. Review highlighted matches and open match details to inspect captures and positions.
Why does my regex work in Python or JavaScript but not here?
Each engine supports a different syntax set. This tester executes Go/RE2, which excludes some features available in Python, JavaScript, and PCRE. The selected compatibility profile explains common differences.
Does this regex tester support lookbehind?
No. Go/RE2 does not support lookbehind or lookahead. Rewrite the expression using captures, anchors, or surrounding match context.
What is the difference between ^ and $ with multiline mode?
Without multiline mode, the anchors refer to the beginning and end of the complete text. With m enabled, they can also match at individual line boundaries.
Is this regex tester safe from catastrophic backtracking?
RE2 guarantees linear-time matching and does not implement constructs that require backtracking. Input, match, capture, and output limits provide additional protection.