Skip to content
Bai
EspañolEnglishEuskara Get started →

Tools

Regex tester

Test your regular expressions live and see what matches and which groups are captured.

Private by design
//

About this tool

Writing a regular expression blind and testing it in code is slow. Here you can see at once which parts of the text match, at what position, and what each bracketed group captures. It is useful for validating emails or phone numbers in a form, pulling data out of a log file, preparing a find-and-replace in your editor, or building a filter in Google Analytics or Search Console.

Type the pattern between the two slashes and the flags in the box on the right, or toggle them with the buttons: g (global), i (ignore case), m (multiline) and s (dotall). “Common patterns” gives you starting points for email, URL, phone and date. Paste your text into “Test string” to see matches highlighted, plus a list showing each match, its index and its groups. “Copy pattern” copies it as /pattern/flags.

It uses your browser’s own JavaScript regex engine, so the syntax is JavaScript (ECMAScript) and may differ slightly from PCRE, Python or Java in areas such as lookbehind and named groups. Nothing is sent to a server. The sample patterns are a starting point: review them before relying on them to validate real data.

Frequently asked questions

What does the g flag do?

It makes the search carry on after the first match and find them all. Without g, the tool shows only the first match.

Why does my regex work here but not in PHP or Python?

Each language has its own flavour. This tool uses JavaScript’s; PHP needs delimiters, and Python differs in details such as named groups ((?P<name>…) versus (?<name>…)). Also check how backslashes are escaped in your code.

How do I make the dot match line breaks too?

Turn on the s (dotall) flag. Without it, the dot matches any character except line breaks.

What are capture groups $1, $2 and so on?

They are the parts of the text matched by each pair of brackets in the pattern, numbered from left to right. In a replacement you can reuse them by writing $1, $2 and so on.

Related tools