Developer

How to Test a Regular Expression (Regex)

4 min read Updated 30 June 2026

You've written a pattern, but does it actually match what you think it matches? A regex tester lets you check that in seconds, without committing anything to code first. You type a pattern, paste in some sample text, and watch the matches light up live, so you can fix mistakes before they ever reach production.

This guide walks you through testing a regular expression with Tooldrop's Regex Tester. It runs entirely in your browser, it's free, and there's nothing to install or sign up for. Paste in sensitive log lines or customer data if you need to, because nothing you type is uploaded anywhere.

Step by step

  1. 1Open the Regex Tester at /dev/regex-tester. There's nothing to download or install, and no account to create, so you can start typing right away.
  2. 2In the Pattern field, type your regular expression using standard JavaScript syntax, for example \d+ to match runs of digits. Leave off the surrounding slashes, because the tool adds the engine wrapper for you.
  3. 3Set your flags in the Flags field. It defaults to g (global) so you see every match, not just the first. Add any combination of g, i, m, s, u, and y, for example gi to also make the match case-insensitive.
  4. 4Paste or type the text you want to check into the Test string box. This is your sample data, like a list of emails, a log snippet, or a paragraph of prose.
  5. 5Watch the Matches panel update live as you type. It shows a running count plus each match in order, with the exact substring and the index where it starts.
  6. 6Read the captured groups under each match. Any parenthesised groups are listed as groups, and if your pattern uses named captures like (?<year>\d{4}), those appear on a named line with the value alongside the name.
  7. 7If something is off, check the friendly error message. An invalid pattern, like an unbalanced bracket, shows a clear 'Invalid regular expression' note instead of failing silently, so you can spot the typo and adjust the pattern or flags until the matches look right.
Try it now — it's free
Runs in your browser. No upload, no sign-up.
Open Regex Tester

Why test a regex before you ship it

Regular expressions are dense, and a single misplaced character can quietly match too much or too little. A pattern that looks correct in your head might grab a trailing space, skip an edge case, or match an empty string forever.

Testing against real sample text closes that gap. By pasting in the actual data your code will see, you catch the false positives and missed cases up front, instead of debugging them later in a failing test or a production incident. It's also the fastest way to learn regex: change one token, watch the match count change, and build an intuition for what each piece does.

Tips for getting accurate results

Start broad, then tighten. Begin with a simple pattern that matches too much, confirm it catches everything you care about, then add anchors and constraints to trim the extras.

Mind your flags. Without the g flag you'll only ever see the first match, which is a common source of confusion. Add i for case-insensitive matching, m so that ^ and $ work line by line, and s so that a dot also matches newlines.

Use capture groups to pull out the parts you need. Wrap a section in parentheses to capture it, or use named groups like (?<area>\d{3}) to label them, then read the values straight from the Matches panel. Finally, paste a few tricky edge cases, like empty lines or unusual characters, so your pattern is tested against the messy reality and not just the happy path.

Is the Regex Tester private and safe?

Yes. The Regex Tester runs entirely in your browser using your own browser's built-in regular expression engine. Your pattern and your test text are never sent to a server, so nothing is uploaded and nothing is stored.

That makes it safe to test against sensitive material, such as log lines with internal hostnames, sample customer records, or anything else you'd rather not paste into a remote service. It's free to use, has no usage limits, and needs no sign-up, so you can run as many patterns as you like without sharing your data.

Frequently asked questions

Do I need to include the slashes around my pattern?
No. Type just the pattern itself, like \d+ or [a-z]+, without the surrounding slashes. The tool builds the regular expression for you and takes the flags from the separate Flags field.
Why am I only seeing the first match?
You're probably missing the global flag. Make sure the Flags field includes g (it does by default), which tells the engine to find every match in your text rather than stopping at the first one.
What regex syntax does the tester use?
It uses JavaScript regular expression syntax and your browser's own RegExp engine. That includes named capture groups like (?<name>...) and the standard flags g, i, m, s, u, and y. Patterns written for some other languages may differ slightly.
Is my test data uploaded anywhere?
No. The matching happens locally in your browser, so your pattern and sample text never leave your device. It's safe to test against sensitive text, and there's no sign-up or limit on how much you use it.

Tools used in this guide

Related guides