Regex Tester (Free, In-Browser)
A regex tester is a tool that runs a regular expression against sample text and shows you exactly what it matches. The tester below builds the pattern entirely in your browser, then reports the number of matches, lists the first matches with their position, and shows the capture groups of the first match, so you can confirm a pattern works before you ever put it in your code.
What a Regex Tester Does
A regular expression, or regex, is a compact pattern that describes a set of strings. Engineers use it to search text, validate input, and pull pieces out of larger documents, all with one short expression instead of pages of hand-written logic. The catch is that a pattern is easy to get subtly wrong, and a wrong pattern can match too much, too little, or nothing at all. A regex tester closes that gap. It compiles your pattern, runs it against text you provide, and shows the result immediately, so you can refine the expression by watching what it actually matches rather than guessing.
How to Use This Regex Tester
- Type your regular expression into the pattern field. Enter only the pattern itself, with no surrounding slashes.
- Set the flags. The default gim means global, case insensitive, and multiline; clear or change them as needed.
- Paste the text you want to search into the test string box.
- Read the result as you type: the match count, the first 20 matches each with their index, and the capture groups of the first match.
- Adjust the pattern until the matches are exactly what you want, then copy it into your code.
Regex Basics: The Building Blocks
Most patterns are made from a small set of pieces. Literals match themselves, while special constructs match by category, position, or repetition. The table below is a quick reference to the parts you will reach for most.
| Piece | What it matches | Example |
|---|---|---|
| Literal | The exact character you type | cat matches the text cat |
| Character class | Any one character from a set | [aeiou] matches one vowel |
| Shorthand class | Common sets: digit, word, space | \d digit, \w word, \s space |
| Quantifier | How many times the prior piece repeats | * zero or more, + one or more, {2,4} two to four |
| Anchor | A position, not a character | ^ start, $ end, \b word boundary |
| Group | Bundles a sub-pattern and captures it | (ab)+ one or more of ab |
| Alternation | One option or another | cat|dog matches cat or dog |
What the Flags Mean
Flags change how the whole pattern is applied. They are single letters set once for the entire expression. The most common are g for global, i for case insensitive, and m for multiline, with s and u available for more specific needs.
| Flag | Name | Effect |
|---|---|---|
g | Global | Find every match, not just the first. |
i | Ignore case | Treat uppercase and lowercase as the same. |
m | Multiline | Make ^ and $ match the start and end of each line. |
s | Dotall | Let the dot match newline characters too. |
u | Unicode | Treat the pattern as a sequence of Unicode code points. |
Common Patterns You Can Reuse
\b\w+@\w+\.\w+\bFinds strings that look like an email address. Use it to spot addresses, not to prove they are valid.
\d+Matches one or more digits in a row. Add a group like
(\d{3}) to capture fixed-length runs.\s+Matches any run of spaces, tabs, or newlines. Handy for collapsing or splitting on gaps in text.
When to Use Regex (and When Not To)
Regex is the right tool when the thing you are looking for follows a pattern but not a fixed string: phone numbers in various formats, dates, log lines, or anything you would describe as “text that looks like this”. It is also ideal for find-and-replace across many variations at once.
It is the wrong tool when a simpler method already exists. If you only need to check whether a word appears, a plain string search is faster and clearer. Structured formats such as HTML, JSON, or programming code should be handled by a proper parser, because their nesting defeats regex and leads to fragile patterns. A good rule is to reach for regex when the pattern has real variation, and to reach for a built-in string method or a parser when it does not.
Is It Private? Yes, It Runs in Your Browser
The pattern, the flags, and the test string are all evaluated locally with the JavaScript RegExp engine that ships in your browser. Nothing you enter is uploaded, logged, or stored on a server, and the tool never uses code evaluation, only the safe RegExp constructor. That means you can test patterns against private logs or sensitive text without it leaving your device.
Related Tools
Compare two blocks of text and see exactly what changed, line by line.
Format, indent, and validate JSON so its structure is easy to read.
Count words, characters, and lines in any text instantly.
Last Thoughts on Testing Regular Expressions
The hardest part of working with regular expressions was never writing them. It was knowing whether the pattern you wrote does what you meant, since one extra character can silently change every match. A tester removes that doubt by letting you watch the matches appear as you type, so you tune the expression against real text instead of shipping a guess.
Build your next pattern here, confirm it against a few sample strings, then drop it into your editor with confidence. For the bigger picture, see our guide to what a programming language is and how regex fits into one, and explore the rest of our free online tools.
Key Takeaways:
- A regular expression is a compact pattern for finding and extracting text; a regex tester shows you what it matches live.
- Enter the pattern without surrounding slashes, set the flags, and paste your test text to see the match count and the first matches.
- Patterns are built from literals, character classes, quantifiers, anchors, groups, and alternation.
- The g flag finds every match, i ignores case, and m makes the anchors work per line.
- Use regex for text that varies by pattern; use a plain search or a parser for fixed strings and structured formats.
- This tester runs entirely in your browser with the RegExp engine and never sends your data anywhere.
Frequently Asked Questions (FAQs)
What is a regex tester?
A regex tester is a tool that runs a regular expression against sample text and shows you what it matches in real time. You type a pattern, supply some test text, and the tester highlights every match, counts them, and reveals the contents of any capture groups, so you can confirm the pattern behaves the way you expect before you put it in your code.
Does this regex tester send my data anywhere?
No. The pattern, the flags, and the test string are all evaluated inside your browser using the built-in JavaScript RegExp engine. Nothing you type is uploaded, logged, or stored on any server, so it is safe to test patterns against private or sensitive text.
Why does my pattern say Invalid pattern?
That message appears when the engine cannot compile what you typed, usually because of an unbalanced bracket or parenthesis, a stray backslash, or an unsupported flag. Read the error text shown next to it, check that every opening bracket has a closing one, and remember that JavaScript regex does not support every feature found in other languages.
What do the flags g, i, and m mean?
The g flag makes the search global so it finds every match instead of just the first. The i flag makes matching case insensitive. The m flag makes the anchors caret and dollar match at the start and end of each line rather than only the whole string. You can combine them, and gim is a common default.
Is JavaScript regex the same as regex in other languages?
The core syntax is shared, so most patterns work the same way across languages. The differences are in the extras: features such as lookbehind, named groups, and the s and u flags vary in support, and some engines like PCRE or Python add syntax that JavaScript does not have. This tester uses the JavaScript engine, which is what runs in the browser.
Can I use this regex tester to validate input?
You can use it to design and check a validation pattern, then copy that pattern into your code. The tester itself is for building and confirming the expression, not for validating live form input. For real validation, remember that regex checks format only, so it confirms an email looks like an address but not that the address exists.
