Skip to main content
ToolsBay

Regex Tester

Test regular expressions live with match highlighting and groups.

Runs entirely in your browser — nothing is uploaded

Flags

0 matches

Enter a pattern to begin.

Frequently asked questions

Which regex flavour is this?

JavaScript's, since it runs in your browser. It is close to PCRE but not identical — there are no possessive quantifiers or recursion, and lookbehind is supported in modern browsers only.

Why is my match count capped?

Results stop at 1000 matches. A pattern that can match the empty string matches at every position, so an uncapped loop over a large subject would lock up the tab.

How do I use named groups?

Write (?<name>...) in the pattern and the captured value appears under that name in the results. In a replacement string, refer to it as $<name>.

What is catastrophic backtracking?

Nested quantifiers such as (a+)+b make the engine try exponentially many combinations on input that nearly matches. It can hang a browser tab — and on a server it is a denial-of-service vector known as ReDoS.

Testing before you ship

A regular expression is easy to write and hard to be sure about. The failure mode is rarely a syntax error — it is a pattern that works on the three examples you tried and quietly mishandles the fourth. Seeing every match highlighted in place, against realistic input, is the fastest way to find that out.

The flags

  • g — without it you get only the first match, which is the most common surprise.
  • m — makes ^ and $ match at each line break rather than only at the start and end of the whole string.
  • s — lets . match a newline. Without it, . stops at line ends, which breaks patterns meant to span lines.
  • i — case-insensitive matching.

Two things worth avoiding

The first is nested quantifiers. A pattern like (a+)+$ looks harmless and takes exponential time on input that almost matches — enough to freeze a browser tab or take down a server. If a pattern feels slow on a long string, that is usually why.

The second is parsing structured formats with regex. HTML, JSON and CSV all have nesting and quoting rules that regular expressions cannot express correctly. Use the JSON formatter or HTML beautifier instead — a real parser will handle the cases your pattern will not.

All developer tools