Regex tester

Test a JavaScript regular expression against real text, see every match highlighted in place, and read the capture groups out one by one.

Flags
Write to hello@beste.co or to support@beste.co for anything urgent. The old address, team@old-domain.example, bounces. Not an address: hello (at) beste.co
3 matches.
Match 1 at 9
Group "user"
Group "host"
Match 2 at 30
Group "user"
Group "host"
Match 3 at 85
Group "user"
Group "host"

Questions

Which flavour of regex is this?+

JavaScript's own, run by your browser. That matters: lookbehind, named groups and unicode property escapes are all here, and PCRE features such as recursion are not.

Why is the g flag always on in the results?+

Because the listing shows every match. Without it the engine returns the first one forever, which looks like a broken page. Your own flags are still shown and used for everything else.

What are named groups good for?+

Reading the result without counting brackets. (?<user>...) gives you match.groups.user, which survives someone adding a group in front of it later.

Why does my pattern hang the page?+

Almost always catastrophic backtracking: a quantifier inside a quantifier, such as (a+)+ or (\w+\s*)*, against a string that nearly matches. The engine tries every split before giving up. Make the inner part specific, or anchor it, and never run a user-supplied pattern on a server.

How do I match across lines?+

The s flag makes a dot match a newline; the m flag changes what ^ and $ mean, so they anchor to each line rather than the whole string. They are unrelated, and reaching for m when you meant s is the most common regex bug there is.

Related tools

The tools are free. So is most of the library.

1935 blocks and 989 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version