Regex tester
Test a JavaScript regular expression against sample text. See every match, its position and its capture groups.
Runs in your browser. Nothing you enter is uploaded.
What it does
Type a regular expression and some text to see what it matches. Each match is listed with its position and the contents of its capture groups, so you can fix a pattern before it goes into your code.
How to use it
- Enter the pattern without the surrounding slashes.
- Enter flags such as g (all matches), i (ignore case), m (multi-line), s (dot matches newline) and u (Unicode).
- Type or paste the test text. Results update as you type.
Worked example
Pattern (\d{2})-(\d{2})-(\d{4}) with flag g on “Born 15-08-1947, republic 26-01-1950.” finds two matches. The first is 15-08-1947 at position 5, with groups 15, 08 and 1947.
How it works
The pattern is compiled with the browser’s RegExp, so the syntax is JavaScript’s. Other languages differ in places: for example, lookbehind and named groups are written differently in some engines. If the pattern is invalid, the browser’s error message is shown.
Questions
Why do I only get one match?
Without the g flag a regular expression stops at the first match.
Why did the page freeze on my pattern?
Some patterns, such as nested repeats like (a+)+, take exponential time on certain input. The tool limits the text length and the number of matches shown, but cannot stop a slow pattern once it is running.
Will this pattern work in Python, Java or Kotlin?
Mostly, for simple patterns. Check the details of the other language’s syntax for anything advanced.
Is my text sent to a server?
No. Everything runs in your browser. Nothing you type is uploaded or stored by us.
Related tools
Need an app or website for your shop? See how to hire us →