130+ free tools. No sign-up. No hidden fees. Explore the toolkit

Regex Tester

Test a regular expression against your own sample text — see every match with its position and captured groups, and catch syntax errors before they reach your code.

Enter the pattern without surrounding slashes, e.g. \d+ or (\w+)@(\w+).

g = all matches, i = ignore case, m = multiline, s = dot matches newlines.

The pattern is tested against this text. Nothing is uploaded.

Matches

Save to Pinterest

How It Works

Regular expressions are patterns for finding text: \d+ finds runs of digits, \w+@\w+ finds simple email-like strings, and ^# finds lines that start with a hash. They are used for validation, search-and-replace, log analysis and data extraction in almost every programming language. A small mistake — a missing bracket, a greedy quantifier — can silently match the wrong text, so testing a pattern against real sample text first is essential.

This tester runs your pattern with your browser’s own JavaScript regex engine, so the results match exactly what the same pattern would do in JavaScript code. It lists every match with its position in the text and the contents of each captured group, and it explains syntax errors in plain language instead of failing silently. Flags work as in JavaScript: g finds all matches, i ignores case, m makes ^ and $ match at line boundaries, and s lets . match newlines.

Worked Example

Test the pattern \d+ with the g flag against the text Order 123, item 45, total 678 and you get three matches: 123 at index 6, 45 at index 16, and 678 at index 26. Test the pattern (\w+)@(\w+) against mail me at ava@example and you get one match, ava@example at index 11, with two captured groups: group 1 is ava and group 2 is example. Test ( — an unclosed group — and the tool reports an error instead.

How to Use This Tool

Type your pattern without surrounding slashes, add any flags, paste your test text and press Test Regex. The results table lists each match in order, with the matched text, its starting index and its captured groups. Use Load Email Sample to try a pattern with groups. If the pattern is invalid, an error message explains what is wrong.

Tips and Practical Advice

Last updated: