About the Regex tester
A regex tester lets you try a regular expression against sample text and see exactly what it matches before you put it in your code. Regular expressions are powerful for searching, validating and extracting text, but a small mistake can make them match too much or nothing at all.
This tester uses the JavaScript regular expression engine, the same one in browsers and Node.js. It lists every match with its position and any captured groups.
How to use the Regex tester
- Type your pattern in the Pattern field without the surrounding slashes, for example
\d{3}-\d{4}. - Add flags in the Flags field, such as
gto find all matches orito ignore case. - Paste the text to search into the Test text editor.
- Click Test expression and review the list of matches, their index and their groups.
Examples
Find every email address
Input
Pattern: [\w.+-]+@[\w.-]+\.[A-Za-z]{2,} Flags: g
Contact ada@example.com or support+billing@shop.co.ukOutput
1. "ada@example.com" (index 8)
2. "support+billing@shop.co.uk" (index 27)Capture groups from dates
Input
Pattern: (\d{4})-(\d{2})-(\d{2}) Flags: g
Released 2026-03-14, patched 2026-04-02Output
1. "2026-03-14" (index 9) groups: ["2026","03","14"]
2. "2026-04-02" (index 29) groups: ["2026","04","02"]Common errors and how to fix them
Invalid regular expression: /(abc/: Unterminated group
A ( has no matching ). Close the group, or escape it as \( if you meant a literal bracket.
Invalid flags supplied to RegExp constructor 'gg'
A flag is repeated or not a real flag. Valid JavaScript flags are d g i m s u v y, each used once.
Only the first match is found
Without the g flag, a JavaScript regex stops after the first match. Add g to find all matches, and m if ^ and $ should match at every line.
Good to know
- Without the
gflag only the first match is shown. Addgto list all matches. - Results are limited to the first 100 matches.
- Common flags:
gglobal,iignore case,mmultiline anchors,slets.match line breaks,uUnicode. - Patterns are tested as JavaScript regex. Syntax from other languages, such as possessive quantifiers, may behave differently or be invalid.
Frequently asked questions
Why does my pattern match nothing?
Check for special characters that need escaping, such as ., ?, ( and +, which must be written as \. and so on to match literally. Also make sure you didn't include the surrounding slashes in the Pattern field.
How do capture groups work?
Parts of the pattern wrapped in parentheses are captured separately. For each match, the tester lists the text captured by each group in order.
Will a regex that works here work in Python or PHP?
Simple patterns usually work the same, but each language has its own differences. Test in the target language before relying on advanced features such as lookbehind or named groups.