How to Test a Regular Expression (Regex)
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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
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?
Why am I only seeing the first match?
What regex syntax does the tester use?
Is my test data uploaded anywhere?
Tools used in this guide
Related guides
Paste any JSON Web Token to read its header and payload in seconds — free, private, and entirely in your browser.
Paste messy JSON, beautify or minify it, and catch errors instantly with this free in-browser JSON formatter.
Paste a JSON array of objects and get clean, spreadsheet-ready CSV in seconds — free, private, and entirely in your browser.