{jsonbody.com}

Regex Tester & Explainer

Test regular expressions with live matching and see each part explained in plain English. Includes capture groups, replace and a clickable regex cheat sheet. Free.

Test and understand regular expressions

Regular expressions are compact but easy to get subtly wrong. Enter a pattern and some sample text, and this tester highlights each match right away. The explanation table breaks your pattern into pieces and says what each one means in plain English, and the details table shows the position and capture groups of each match. You can also try a replacement, and click any item in the cheat sheet to add it to your pattern. It uses your browser's JavaScript regex engine, so what works here will also work in JavaScript and Node.js.

Patterns run in a background worker and are stopped after 1.5 seconds. A runaway expression gives you an error message and your tab keeps working.

Flags

  • g finds all matches rather than just the first.
  • i ignores upper and lower case.
  • m makes ^ and $ match at each line.
  • s lets . match line breaks too.
  • u enables full Unicode matching, including \p{L} for letters in any language.

Example: dates and replacement

This pattern finds dates, with named groups for each part. Enabling replacement then rewrites them in a new order. Inside the replacement, $1 refers to the first group and $<name> to a named group.

Pattern, text and replacement
Pattern:      (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})
Text:         Shipped on 2026-03-14 and 2026-04-02.
Replace with: $<d>/$<m>/$<y>
Result:       Shipped on 14/03/2026 and 02/04/2026.

Avoiding catastrophic backtracking

Nested quantifiers such as (a+)+$ can take exponentially longer as input grows. On a server, this is a real denial-of-service risk, known as ReDoS, when the input comes from users. If the tester stops your pattern, make the inner part more specific so there is only one way to match each character. Anchoring the pattern and limiting input length also help. Other languages can differ in syntax and features, so test again in your target language before shipping.

Frequently Asked Questions

Why does my regex match too much?

Quantifiers are greedy by default. Change .* to .*? for the shortest match, or use a specific class such as [^"]*.

Will this pattern work in Python or PHP?

Much of the syntax is shared, but details differ. For example, Python writes named groups as (?P<name>...). Re-test in your language if the pattern is complex.

How do I match a literal dot or bracket?

Put a backslash before it, as in \. or \[. Unescaped, a dot matches almost any character.

Is there a limit on matches?

Matching stops at 2000 matches, and the details table shows the first 200. This keeps the page responsive.