Regex tester

Live matches and capture groups with a cheat sheet.

FreeRuns in your browserNo signupUpdated 2026-10-29

Results stop after 1,000 matches.

Pattern

Matches

Matches

3

All occurrences

Groups

2

Named: user, domain

Highlighted text

Contact sales@example.com or support@msh-technologies.co.in for a quote.
Invalid: nobody@localhost, "at" example dot com
Second line: priya.nair+web@example.org

Matches and capture groups

#MatchAtuserdomain
1sales@example.com8salesexample.com
2support@msh-technologies.co.in29supportmsh-technologies.co.in
3priya.nair+web@example.org134priya.nair+webexample.org

Cheat sheet

.Any character except newline (any with the s flag)
\d \w \sDigit, word character, whitespace (capitals negate)
[abc] [^abc] [a-z]One of, none of, range
* + ? {2,5}Zero or more, one or more, optional, between 2 and 5
*? +?Lazy versions: match as little as possible
^ $ \bStart, end (of line with m flag), word boundary
(x) (?:x) (?<name>x)Capture group, non-capturing group, named group
a|bEither a or b
(?=x) (?!x)Lookahead: followed by, not followed by
\. \? \(Escape a special character with a backslash

About this tool

How it works and how to read the result.

Need this done for you?

Web app & SaaS development

SaaS products and web apps, from first version to scale.

See the service

What it does

The regex tester runs your pattern against sample text as you type and highlights every match in place. A table below lists each match with its position and the contents of every capture group, using group names as headings when you have them. The five common flags are checkboxes, a copy button gives you the finished /pattern/flags literal, and a cheat sheet covers the syntax most people forget. Invalid patterns show the engine's error instead of breaking the page, and matching is capped at 1,000 results so a pattern that matches every character stays responsive.

How to use it

  1. Type the pattern without surrounding slashes. Start simple and add to it.
  2. Paste the text you want to search. Several lines are fine.
  3. Set the flags: g for all matches, i to ignore case, m if ^ and $ should work per line.
  4. Watch the highlights and the groups table, then copy the literal when it does what you want.

How to read the result

The example pattern (?<user>[\w.+-]+)@(?<domain>[\w-]+\.[\w.-]+) against the sample text gives 3 matches and 2 groups. The table shows sales@example.com at position 8 with user sales and domain example.com, and so on. nobody@localhost is not matched, because the domain group demands a dot, which is exactly the kind of case you should put in the sample on purpose.

"No match" with a valid pattern usually means an anchor or a flag. A pattern starting with ^ only matches at the start of the whole text unless m is on. A pattern with uppercase letters will not match lowercase input unless i is on.

An empty match, shown as a thin highlight, means the pattern can match zero characters; a* does this between every letter. Add + or a required character to tighten it.

Patterns like these end up in form validation and routing in our web app development work. For schedules rather than text, see the cron expression generator.

Questions

Frequently asked.

Which regex flavour is this?

JavaScript, as used in browsers and Node. Most patterns behave the same in Python, Go and Java, but a few features differ, such as lookbehind support, possessive quantifiers and named group syntax. If a pattern is destined for another language, test the final version there too.

Why does my pattern match only once?

The g flag is off, so the engine stops after the first match, which is how JavaScript's match and exec behave without it. Turn g on to list every occurrence. The m flag is separate: it makes ^ and $ match at line breaks instead of only at the ends of the text.

What are named capture groups?

Writing (?<year>\d{4}) instead of (\d{4}) gives the group a name, so your code can read match.groups.year rather than counting parentheses. The results table uses the names as column headings, and the pattern stays readable when it grows.

Your next move

Like what you see? Tell us about it.

A process that takes too long, a website that undersells you, or an idea ready to take shape. Tell us where you are and we will suggest a useful next step.

India · Working with clients worldwide

We reply within a working day. No spam, ever.