Reach us at hello@mytoolstudio.com or support@example.org any time.No matches yet.
How to use
Type your pattern and flags
Enter the regular expression without the surrounding slashes and tick the flags you need. Pick an entry on the Patterns tab to load a ready-made pattern with sample text.
Paste the test text
Put the text to search in Test string. Matches are highlighted in alternating colors, and a syntax error, or a pattern that runs too long, appears in red.
Use the result tabs
Read the Match table, try a substitution under Replace, build output with List, or read Explain. Copy code for your language from the Code tab, or download the matches as CSV.
Why Regex Tester
- Match table, replace, list, split and a token-by-token explanation.
- Unit tests for lines that should or should not match.
- Code generator for JavaScript, Python, PHP, Java, C# and Go.
- Runs in a worker with a time limit, so catastrophic patterns cannot freeze the tab.
JavaScript regex tester cheat sheet
These are the building blocks you will use most often. They work the same in this tester, in browsers and in Node.js. Combine them with the flags above the test string: g finds all matches instead of the first, i ignores case, m makes ^ and $ work per line, s lets . match line breaks, u turns on full Unicode, y makes each match start where the last one ended, and d records group positions.
| Token | Meaning | Example |
|---|---|---|
| . | Any character except a line break (unless the s flag is on) | a.c matches abc |
| \d, \w, \s | Digit, word character (A-Z, a-z, 0-9, _), whitespace | \d{3} matches 123 |
| [abc], [^abc] | One character from the set, or not in the set | [aeiou] matches a vowel |
| ^ and $ | Start and end of the text (or of a line with m) | ^Hello |
| *, +, ? | 0 or more, 1 or more, 0 or 1; add ? to make them lazy | a+? matches one a |
| {n,m} | Between n and m repetitions | \d{2,4} |
| ( ) and (?: ) | Capture group and non-capturing group | (\d+)-(\d+) |
| (?<name> ) | Named capture group | (?<year>\d{4}) |
| a|b | Either a or b | cat|dog |
| \b | Word boundary | \bcat\b skips concat |
| (?= ), (?! ) | Lookahead and negative lookahead | \d+(?=px) |
| (?<= ), (?<! ) | Lookbehind and negative lookbehind | (?<=\$)\d+ |
Replace, List and Split, side by side
The three output tabs use the same pattern in different ways. With the sample pattern (?<user>[\w.+-]+)@(?<domain>[\w-]+(?:\.[\w-]+)+) on the text hello@mytoolstudio.com or support@example.org:
| Tab | Setting | Result |
|---|---|---|
| Replace | $<user> at $<domain> | hello at mytoolstudio.com or support at example.org |
| List | $<domain>\n | mytoolstudio.com, then example.org on the next line |
| Split | (no setting) | The text between matches, plus each capture group, as a list |