Regex Tester
Test a regular expression against your text and see every match highlighted, with positions and capture groups. Uses Go (RE2) syntax, with clear errors for unsupported features.
Test Your Regex Pattern
Results update as you type. Patterns use Go (RE2) syntax.
Examples
Load one into the tester:
Match Results
Enter a pattern and some text, or load an example, to see matches.
What This Regex Tester Does
Type a regular expression and some text, and the tester highlights every match, lists each match's position and capture groups (including named groups), and explains errors. It's useful for building a pattern step by step, checking what a pattern from someone else's code actually matches, or extracting data from logs and text.
Patterns run with Go's regexp package, which uses the RE2 syntax. Most everyday patterns behave the same in JavaScript, Python, PHP and Java, but some features differ; see the comparison below before copying a pattern into another language.
How to Use It
- Enter a pattern, without delimiters, or paste a JavaScript literal such as
/\d+/gi. - Tick any flags: case insensitive, multiline (^ and $ per line) or dot matches newline.
- Paste the text to search. Results update as you type: highlighted matches, then each match with its groups.
- If the pattern doesn't compile, the error explains why and, for features RE2 lacks, what to do instead.
Positions are character offsets counted from 0, so "characters 5–9" means the match starts at the sixth character.
Regex Syntax Cheat Sheet
| . | Any character except a newline (add the s flag to include newlines) |
|---|---|
| \d \D | A digit 0–9 / anything that isn't one |
| \w \W | A word character (ASCII letters, digits and _) / anything else |
| \s \S | Whitespace (space, tab, newline and similar) / anything else |
| [abc] [^abc] [a-z] | One of the listed characters / none of them / a range |
| \p{L} \p{Greek} | Unicode categories and scripts, e.g. any letter, any Greek character |
| * + ? | Zero or more / one or more / zero or one |
|---|---|
| {n} {n,} {n,m} | Exactly n / at least n / between n and m |
| *? +? ?? {n,m}? | Lazy versions: match as little as possible |
| ^ $ | Start / end of the text (of each line with the m flag) |
|---|---|
| \A \z | Start / end of the text, regardless of flags |
| \b \B | Word boundary / not a word boundary (ASCII word characters) |
| (…) (?:…) | Capture group / group without capturing |
| (?P<name>…) (?<name>…) | Named capture group (both spellings work in Go) |
| a|b | Either a or b |
To match a special character literally, escape it with a backslash: \. \* \( \?.
How the Flags Change Matching
Case insensitive (i)
Pattern hello on "Hello WORLD hello": 1 match without the flag, 2 with it.
Multiline (m)
Pattern ^word on three lines where the second starts with "word": 0 matches without the flag (^ means the start of the whole text), 1 with it.
Dot matches newline (s)
Pattern start.*end on "start", "middle", "end" on separate lines: 0 matches without the flag, 1 with it.
Go (RE2) Compared With Other Regex Flavours
| Feature | Go / RE2 (this tester) | Other engines |
|---|---|---|
| Lookahead / lookbehind (?=…) (?<=…) | Not supported | JavaScript, Python, PCRE, Java, .NET |
| Backreferences \1, \k<name> | Not supported | JavaScript, Python, PCRE, Java, .NET |
| Atomic groups, possessive quantifiers | Not supported (not needed) | PCRE, Java; atomic groups also in .NET and Python 3.11+ |
| Catastrophic backtracking | Can't happen: runs in linear time | Possible with patterns like (a+)+ |
| \b and \w | ASCII only | Often Unicode-aware, depending on flags |
| Named groups | (?P<name>…) or (?<name>…) | (?<name>…); Python also (?P<name>…) |
| Flags | Inline (?i) (?m) (?s); this tool's checkboxes add them | JavaScript /…/gimsuy, Python re.I etc. |
If your pattern needs lookarounds or backreferences, it won't run here. Test it in a tool for the language you'll use. Patterns that work here usually work in other languages too, but check \b, \w and named groups.
Tips and Common Problems
- No matches: remove ^ and $ if you're searching inside longer text, check that special characters are escaped, and check the case-insensitive flag.
- Matches too much:
.*is greedy; try the lazy.*?, a negated class like[^"]*, or add \b word boundaries. - Validating whole values (a username, a postcode): anchor both ends with ^ and $ so extra characters aren't allowed.
- Emails, URLs and HTML: simple patterns are fine for finding them in text, but for strict validation or parsing HTML, use a proper parser or library.
- Performance in other languages: nested quantifiers such as
(a+)+are safe here but can hang backtracking engines. The tester warns when it sees them.
How Your Input Is Handled
The pattern and test text are sent to Orbit2x's server, which runs the match and returns the results. They aren't saved. Avoid pasting secrets or personal data you wouldn't send to a website. See the privacy policy.
Frequently Asked Questions
Will a pattern tested here work in JavaScript or Python?
Usually, for patterns built from classes, quantifiers, groups, alternation and anchors. The main differences are in the comparison table: \b and \w are ASCII-only in Go, and Go doesn't accept lookarounds or backreferences, which the other languages do.
Why do I get "invalid or unsupported Perl syntax"?
The pattern uses a feature RE2 doesn't have, most often lookahead (?=…), lookbehind (?<=…) or a backreference. The error box says which one and suggests an alternative.
Does the g (global) flag matter?
No. The tester always lists every match, up to 500 in detail. Pasting /pattern/g is fine.
Where can I find ready-made patterns?
The examples above load into the tester. The regex library has more patterns for common formats.