Common: g (global), i (ignore case), m (multiline)
Result:
No results yet.
Advertisement
What is a regex tester? A regex tester runs a regular expression against sample text so you can see what it matches before using it in code. This one uses your browser's JavaScript regex engine, takes a pattern, optional flags and test text, highlights the matches when you click Run Test, and shows an error message if the pattern is invalid.

What is a regex tester?

A regular expression is a compact pattern for finding text, such as every email-like string, every date, or every word that starts with a capital letter. They are powerful and easy to get wrong. A tester lets you try a pattern on real text first, so you find the mistake here and not in production.

This regex tester has three inputs: Regex Pattern, Flags and Test Text. Enter the pattern without the surrounding slashes, for example \bword\b. Type flags as plain letters, such as gi. Press Run Test and the text appears below with every match marked in yellow. The pattern runs through the JavaScript RegExp engine in your browser, so it behaves like regex in Node.js, React or any web page.

The tester stays simple on purpose. It does not run live as you type, and it does not list capture groups, count matches or perform replacements. Without the g flag only the first match is highlighted, which is how JavaScript works. Patterns for PHP, Python or Java can differ from JavaScript, so confirm there.

How to test a regular expression

  1. Type your pattern into Regex Pattern without slashes. For example, \d{4}-\d{2}-\d{2} to find dates like 2026-11-05.
  2. In Flags, type the letters you need, for example g for all matches, i to ignore case, m for multiline. Leave it empty for none.
  3. Paste or type the sample into Test Text. Both the pattern and the text must be filled in, or the tool asks you to enter them.
  4. Click Run Test. Matches are highlighted in the result box. If nothing matches, you see the text with a No matches note.
  5. If the pattern is invalid, a red Invalid regex message appears under the box with the browser's explanation. Fix it and run again.
  6. Click Copy Pattern to copy the pattern text, without flags, to your clipboard.

What this regex tester does

Highlighted matches

Each match is wrapped in a yellow highlight inside your own text, so you see exactly where it starts and ends.

Free-form flags

Any flags your browser supports can go in the Flags box, including g, i, m, s, u and y.

Error messages

A bad pattern, such as an unclosed bracket or an unknown flag, produces an Invalid regex message with the engine's explanation.

Safe display of text

Characters like less-than and ampersand in your sample are shown as text, not interpreted as HTML, so you can test patterns against markup.

Copy Pattern

One click copies the pattern so you can paste it into code or a search box.

JavaScript engine

It uses the same regular expression engine as web pages and Node.js, so results match what your front-end code will do.

Who uses it, and for what

  • JavaScript and Node developers. Try a validation pattern on good and bad inputs before wiring it into a form.
  • SEO and content people. Test a pattern for Search Console filters or a redirect rule against sample URLs. For slugs, see the slug generator.
  • Data cleaners. Check that a pattern finds every phone number or SKU in a messy block of pasted text.
  • Students. Learn what \b, .*? or [A-Z] do by watching the highlight change as you edit the pattern. For the JSON a pattern might run against, see the JSON formatter.
  • WordPress and site admins. Check a pattern before using it in a search-and-replace plugin or an .htaccess rule, then confirm in that system, which may use a different flavour.

Tips for writing patterns that work

  • Add the g flag to see all matches. Without it only the first match is highlighted.
  • Use i for case-insensitive and m so that ^ and $ match at each line, not only at the whole text.
  • Greedy patterns like .* match as much as possible. Try .*? when your highlight swallows too much.
  • A very nested pattern such as (a+)+b can freeze the tab on some text. If the page hangs, refresh and simplify the pattern.
  • Escape special characters you mean literally: . ? * + ( ) [ ] { } | \ ^ $.
  • To see how long or repetitive your sample text is before matching, run it through the word counter.

Is it safe? Privacy and limits

The pattern and text are processed by your browser and are not sent anywhere by this tool, nor saved. The tester only supports the JavaScript regular expression flavour. It does not explain a pattern in words, test replacements or show capture groups. Results may differ in PHP, Python, Java or grep, so test in the target language before relying on a pattern for important data cleanup.

Regex tester FAQ

Enter the pattern without slashes, add any flags, paste the test text and click Run Test. Matches are highlighted in yellow in the result box. If nothing matches, the text is shown with a No matches note. If the pattern is invalid, an Invalid regex message appears. The tool does not update as you type, so click the button again after each change. Both the pattern and the text must be filled in.

JavaScript, also known as ECMAScript. The tester passes your pattern and flags directly to the browser's RegExp constructor, so it supports whatever your browser supports, including lookahead, named groups and, in modern browsers, lookbehind. It does not support PCRE-only features such as possessive quantifiers or inline comments. If you are targeting PHP, Python or Java, the basics are the same, but the details can differ. For most everyday patterns, such as digits, word boundaries and character classes, the flavours behave alike.

Because the global flag is off. In JavaScript, a regex without g stops after the first match. Type g into the Flags box and run the test again to highlight every match. If you want case-insensitive matching as well, use gi. The order of the letters does not matter. The tool deliberately follows JavaScript rules, so what you see is what your code will do. Remember that a pattern with no flags at all is perfectly valid; it just stops early.

Anything the browser accepts. The common ones are g (all matches), i (ignore case), m (^ and $ work per line), s (dot matches line breaks) and u (full Unicode). The y sticky flag also works but only matches at one position. Unknown or repeated flags give an Invalid regex error. Type them together without spaces or commas, for example gim. If you are unsure whether a flag exists, try it: the tool will tell you right away if the browser rejects it.

No. It only highlights the full text of each match. You cannot see what $1 or a named group captured, and there is no replace field. If you need that, test the groups in your browser console or code. The highlight is still useful to check that the overall pattern finds the right spans, which is where most mistakes happen. Many developers use a quick console test such as 'text'.match(/(a)(b)/) for that part.

Usually because of escaping or flavour. In a JavaScript string, backslashes must be doubled: "\\d+", while this tester takes a single backslash. Literal regex slashes and flags are also separate here. If your target is PHP or Python, a feature like named groups syntax or lookbehind may differ. Check that the flags in your code match the ones in the Flags box. It also helps to test the same pattern on a few examples that should not match.

No. The matching happens in your browser using JavaScript. The text and pattern are not uploaded, logged or stored by this tool, and refreshing the page clears them. As with any page, avoid pasting passwords or private records you do not need to test. The result box shows your text as plain text, so sample HTML is displayed safely and not executed. The result is shown in a box that wraps long lines.

Yes. Some patterns, such as nested quantifiers like (a+)+b, can take extremely long on text that almost matches. This is called catastrophic backtracking. The tester has no timeout, so the tab may become unresponsive until you close or refresh it. Simplify the pattern, make groups specific, or anchor it. The tool does stop at 10,000 matches in global mode. A refresh restores the page immediately. Keep samples short while experimenting.

Advertisement