Test patterns without the guesswork
Regular expressions are compact, powerful and famously easy to get wrong. A pattern that looks right can silently match nothing at all, or match far more than you intended, and you usually only find out once it is sitting in production code. This tester gives you a tight feedback loop instead: type a pattern, paste some real text underneath, and the match count and match list update on every keystroke. Each match is listed with its index, the zero-based character position where it starts, which is exactly the number JavaScript reports and the one you need when slicing strings.
If the pattern is invalid you get the engine's actual error message under the pattern box, not a blank result. That makes it quick to spot the classic mistakes: an unclosed bracket, a stray quantifier, or a special character that needed escaping.
Everything runs in your browser using JavaScript's built-in RegExp engine. Your pattern and your test text are never uploaded, stored or seen by anyone, so it is safe to test against logs, emails, exports or code you would not paste into an unknown website.
Mini cheat sheet
.any single character except a line break\ddigit,\wword character,\swhitespace. Capitals negate them:\D,\W,\S[abc]any of a, b or c;[^abc]anything except them;[a-z]a range*zero or more,+one or more,?zero or one,{2,4}between two and four^start and$end of the text, or of each line when the m flag is on\bword boundary, ideal for whole-word searches(cat|dog)either alternative, grouped\.a literal dot. Escape the same way for+ * ? ( ) [ ] { } | \ ^ $
Worked examples
Understanding the three flags
The g (global) flag is the one you will use most. Without it the engine stops at the first match, which is why this tool ticks it by default. With it, the engine carries on from the end of each match and returns them all.
The i flag ignores case, so a search for postcode matches Postcode and POSTCODE too. It is the quickest fix when a pattern works in one place and mysteriously fails in another: the culprit is often just capitalisation.
The m flag changes what the anchors mean. Normally ^ and $ mark the start and end of the entire text; with m they mark the start and end of every line, which is what you want when scanning logs or lists line by line. Note that m does not change the dot, which still refuses to cross line breaks. If you need to match across lines, use a class like [\s\S] instead.
One caution before you copy a pattern into your codebase: this page uses the JavaScript flavour of regex. The core syntax above is shared by almost every language, but advanced features vary between flavours, so give the pattern a final test wherever it will actually run.
Frequently asked questions
Is my pattern or test text uploaded anywhere?
No. The pattern runs against your text entirely in your browser using JavaScript's built-in regular expression engine. Nothing you type is uploaded, stored or seen by anyone, so it is safe to test against logs, emails or code.
What do the g, i and m flags do?
The g flag finds every match rather than stopping at the first. The i flag ignores case, so cat matches Cat and CAT. The m flag makes the ^ and $ anchors match at the start and end of every line instead of only the whole text.
Why does my pattern show as invalid?
The pattern breaks a rule of regular expression syntax, most often an unclosed bracket or group, or a quantifier like + with nothing before it. The error message under the pattern box names the problem. To match a special character literally, put a backslash before it.
Why does the dot not match my line breaks?
In JavaScript the dot matches any character except a line break by default. If you need to cross lines, match the break explicitly with something like [\s\S], which means any whitespace or non-whitespace character.
Which flavour of regex does this use?
It uses JavaScript's RegExp engine, the same one that runs in every browser and in Node.js. Core syntax matches other flavours such as PCRE and Python, but some advanced features differ, so always test patterns in the environment where they will run.