Free developer tool

Regex Tester

Enter a pattern, flags and test text. The tester lists every match with its position and capture groups so you can debug a regular expression quickly.

Report a problem or suggest a fix for this tool

What is regex tester?

Regular expressions describe patterns in text, such as emails, dates or IDs. They are powerful and easy to get wrong, so testing against sample text saves time.

This tester uses the JavaScript regex engine in your browser. It shows each match, where it starts and what each capture group caught.

How to use the regex tester

  1. Type the pattern without slashes.
  2. Add flags such as g for all matches, i to ignore case and m for multiline.
  3. Paste your test text and read the matches.

How the regex tester works

The tool builds a RegExp object from your pattern and flags and runs it across the text, collecting up to 200 matches.

Worked example

The pattern \d+ with flag g on the text 12 apples and 7 pears finds 12 and 7.

Common uses of the regex tester

  • Building a pattern to validate emails, dates or IDs.
  • Finding and replacing text in an editor with a safe pattern.
  • Extracting data from logs and exports.
  • Learning regular expression syntax with instant feedback.
  • Debugging why a pattern matches too much or too little.

Tips and common mistakes

Start simple and build up. Add one part of the pattern at a time.

Use anchors and word boundaries to avoid matching more than you intend.

Background: what to know before you rely on it

Regular expressions were invented by mathematician Stephen Kleene in the 1950s and entered programming through Unix tools in the 1970s. They are compact but can be cryptic. Greedy patterns match as much as possible, so adding a question mark makes them lazy. Anchors such as caret and dollar fix a match to the start or end of a line. Capture groups pull out parts of a match. A badly written pattern can take exponential time on some inputs, a problem called catastrophic backtracking, so test with long strings. For complex formats such as HTML or full email rules, a proper parser is often a better tool.

Private, free and fast

This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all developer tools, or browse the full list of tools.

Field by field guide

  • Pattern: Type your value. The example is \b\w+@\w+\.com\b.
  • Flags: Type your value. The example is g.
  • Test text: Type or paste your text here. Use a new line for each entry where the label says so.

Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.

Writing regular expressions you can trust

A regular expression describes a text pattern. The tester highlights matches live, so you can refine a pattern before you put it into code.

Expert tips

  • Start simple and add one feature at a time, testing after each change.
  • Anchor patterns with ^ and $ when you need to match a whole value, such as a postal code.
  • Use non greedy quantifiers such as .*? to stop at the first closing delimiter.
  • Escape special characters like dot and parenthesis when you want them literally.
  • Test with both matching and non matching samples, including empty strings.

Regex engines differ slightly between languages. Confirm that the features you use, such as lookbehind, are supported in your runtime.

Frequently asked questions

What do the flags mean?

g is global, i ignores case, m is multiline, s lets the dot match new lines and u enables Unicode.

Why does my pattern not match?

Check escaping. Backslashes need care in JavaScript strings but not in this box.

Does it support PCRE or Python?

No. It uses the JavaScript engine.

Embed this tool on your website

Copy the code below and paste it into your page or blog post. The tool is free to embed, runs in the visitor's browser and needs no account. Please keep the credit link.

Related tools

Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Do not paste live secrets into any website.