Skip to content
Pricing Failed solves are free. You only pay when it works. See prices

Free tools

Regex tester

Write a regular expression and see its matches highlighted as you type, with capture groups listed and a replacement preview.

Pattern

Test text

Matches in the text

The text appears here with every match highlighted.

Match list

Each match is listed here with its position and capture groups.

Replace

Type a replacement to preview the result.

In code


                    
                

When to use it

You need to pull a value out of text, such as a price, an id or a JSON blob in a script tag. Write the pattern here and watch what it matches as you type, before you put it in your code.

Which flavour this is

Your browser's JavaScript engine runs the pattern, so JavaScript's rules apply. Named groups are written (?<name>…). Lookbehind works. Possessive quantifiers and atomic groups don't exist. The "In code" panel also writes the pattern for Python's re module, and converts the parts that differ, such as (?P<name>…).

The flags

  • g finds every match. Without it you get the first one only.
  • i ignores case. m makes ^ and $ match at each line break. s lets . cross line breaks, which is what you want for a pattern that spans lines of HTML.
  • u treats the text as Unicode code points and turns on \p{…}. y matches only at the exact spot where the last match ended.

Limits on this page

The text is capped at 200 kB and the list at 5,000 matches. A pattern that can match nothing, such as a*, is stepped forward one character at a time so it can't loop. One thing a page can't stop is a single match attempt that takes a very long time. Nested quantifiers like (a+)+$ cause that. If the tab freezes, that's what happened. Reload and tighten the pattern.

When not to use a regex

To pull a value out of a script tag or an inline JSON blob, a regex is the right tool. To select elements in HTML, use the CSS selector tester or the XPath tester. Markup nests, and patterns don't.

Questions people ask

How do I test a regular expression?

Type the pattern, set the flags you need and paste some text. Matches are highlighted as you type and each capture group is listed underneath.

What do the flags g, i, m and s do?

g finds every match instead of the first. i ignores case. m makes ^ and $ match at each line break. s lets the dot match newlines too.

Should I parse HTML with a regex?

For pulling one value out of a known string, such as a JSON blob inside a script tag, a regex is fine. For walking a document, use a parser with CSS selectors or XPath. Nested tags are where regexes go wrong.

Will my pattern work in Python?

Mostly. The main differences are named groups, written (?P<name>...) in Python, and flags, which are passed as re.I, re.M and re.S. The page shows the Python form of your pattern.

Get started

Blocked by bot protection? $5 is 5,000 solves.

No subscriptionCredit never expiresFailed solves are free