Skip to content
ToolFarmToolFarm
DeveloperPopular

Regex Tester and Debugger

Test and debug regular expressions online in real time, with capture groups and live match highlighting. Free and in your browser, no upload.

2 min read

Toggle each flag like you would in a JavaScript regex literal.

no matches/\b(\w+)\b/g

Paste some text and you'll see matches here.

What this tool does

Real-time regex tester. Write a pattern, paste your text, set the flags and see matches and capture groups update instantly. Built to help you understand what your regex actually does without opening a console.

In developer flows it pairs naturally with JSON formatter. For long passages, word counter helps you understand the scope of what you're processing.

What you can use it for

  • Check whether an email or phone number matches your pattern.
  • Pull specific fragments out of a string using capture groups.
  • Debug a regex that's misbehaving in production.
  • Learn regex by watching which parts of the text get highlighted.

How to use it

  1. Type the pattern in the Pattern field, without the leading and trailing slashes.
  2. Toggle the flags you need: g, i, m, s, u, y by default, plus d and v under advanced.
  3. Paste the text you want to test.
  4. Matches are highlighted and capture groups appear below.

Everything runs inside your browser. No file is uploaded to any server. See more tools in this field.

What every regex flag does

These are the flags JavaScript RegExp supports. Combine them as needed. The chips above match this list exactly.

JavaScript regex flag reference
FlagNameWhat it does
gglobalFinds every match instead of stopping at the first.
iignore caseMatches upper and lower case interchangeably.
mmultilineMakes ^ and $ match the start and end of each line.
sdot matches newlinesLets the dot match newline characters too (dotAll).
uunicode modeTreats the pattern as Unicode and enables \p{…} categories. Cannot be combined with v.
ysticky searchMatches only from lastIndex, without advancing through the string.
dmatch indices (advanced)Adds the start and end index of every match to the result.
vunicode sets (advanced)Enables Unicode set notation like [\p{ASCII}--\p{Lu}]. Replaces u; cannot be combined with it.

Regex patterns you'll keep coming back to

These patterns cover the most common validations. Copy, paste, adjust to your case. Remember to escape special characters when you need them literal.

  • Basic email

    ^[\w.+-]+@[\w-]+\.[\w.-]+$

    Covers 95% of real-world emails. Not full RFC, but it works in production.

  • International phone

    ^\+?[1-9]\d{6,14}$

    E.164 format: optional +, 7 to 15 digits, no dashes or spaces.

  • http(s) URL

    ^https?:\/\/[\w.-]+(?:\/\S*)?$

    Accepts http and https, domain and optional path, querystring not required.

  • Hex color

    ^#?(?:[0-9a-fA-F]{3}){1,2}$

    Three or six hex characters, with or without the hash.

  • ISO date

    ^\d{4}-\d{2}-\d{2}$

    YYYY-MM-DD format. Does not validate the date exists, only the shape.

  • Slug

    ^[a-z0-9]+(?:-[a-z0-9]+)*$

    Lowercase letters and digits separated by a hyphen. SEO standard.

Mistakes that cost time

  • The dot is not always a dot

    In regex, . means any character except newline. If you need a literal dot, escape it: \.

  • Greedy vs lazy

    .* is greedy and grabs everything it can. If you want the minimum possible, use .*? to make it lazy.

  • Forgetting the g flag

    Without g, .match() in JavaScript returns only the first match. To find them all, add g to the flags.

  • Misplaced anchors

    ^ and $ tie the pattern to the start and end of the line. If you put them in the wrong spot, nothing matches even when the pattern is correct.

Other tools people reach for in the same flow.

Developer

Frequently asked questions

Which regex engine does the tool use?

It uses the JavaScript engine, so the syntax follows the ECMAScript standard. If you paste a regex written for PCRE (PHP, Python) or Perl, some advanced constructs such as variable-length lookbehinds may not behave the same.

Which flags can I use?

The JavaScript standard flags: g (global), i (case insensitive), m (multiline), s (dotAll), u (unicode) and y (sticky). You can combine them freely.

What are capture groups?

Parentheses in a regex group parts of the match so you can reuse them. The tool shows each numbered group under every match so you see exactly what each one captures.

Is my text sent to a server?

No. Both the regex and the text are evaluated in your browser. Nothing leaves your machine, so you can safely test with sensitive data.