ToolGenie.org Logo

Regex Tester

Test a regular expression against your own text β€” live highlighting, capture groups, flags and a replace preview, all inside your browser.

Flags

Enter a regular expression above to start matching.

Replace

Use $1 and $2 for numbered groups, $<name> for a named group, $& for the whole match and $$ for a literal dollar sign.

Regex cheat sheet β€” common tokens
TokenMeaning
\dAny digit from 0 to 9.
\wAny word character: a letter, a digit or an underscore.
\sAny whitespace: space, tab, newline or carriage return.
.Any single character except a line break, unless the s flag is on.
*The previous item zero or more times, taking as much as it can.
+The previous item one or more times.
?The previous item zero or one time β€” or makes a quantifier lazy.
{n,m}The previous item at least n and at most m times.
[]A character class: any one of the characters listed inside.
()A capturing group: remembers what it matched for $1, $2 and so on.
|Alternation: match the expression on the left or the one on the right.
^Start of the string, or start of a line when the m flag is on.
$End of the string, or end of a line when the m flag is on.
\bA word boundary: the edge between a word character and anything else.
(?:)A non-capturing group: groups the pattern without numbering it.
(?=)Positive lookahead: what follows must match, but is not consumed.
(?!)Negative lookahead: what follows must not match at this position.

Your pattern and your test string never leave this page β€” everything is compiled and matched by JavaScript running in your own browser.

How to Use the Regex Tester

  1. Type your pattern into the field between the two slashes. The delimiters are drawn for you, so enter the expression itself and nothing else.
  2. Tick the flags you need: g for every match, i for case-insensitive, m for per-line anchors, s so the dot matches newlines, u for full Unicode and y for sticky matching.
  3. Paste the text you want to check into the test string box, or press "Load example" to start from a working pattern with named groups.
  4. Read the results live: every match is highlighted in the preview, and the list below shows each match with its index, its numbered groups and any named groups.
  5. Open the Replace box to preview a substitution with $1 or $<name>, then copy the match list as JSON or copy the replaced text in one click.

What Is a Regex Tester?

A regular expression β€” a regex β€” is a small pattern language for describing the shape of text rather than one exact string: three digits in a row, a word boundary followed by a capital letter, anything sitting between two quotation marks. That density is its strength and its trap, because one stray bracket or one greedy quantifier quietly changes what the pattern captures. A regex tester closes the feedback loop your editor cannot: you type the expression and watch every match light up in your own sample text, character by character, before the pattern ever reaches your codebase.

This tester runs the JavaScript regular expression engine β€” the same RegExp object behind your browser and Node.js β€” and not PCRE, RE2, Python's re module or .NET. The difference matters the moment you copy a pattern between languages. JavaScript has no \A or \z anchors, so you use ^ and $ and reach for the m flag when you want them to mean each line; there are no possessive quantifiers, no atomic groups and no recursion; and lookbehind such as (?<=...) is supported by modern browsers but not by every engine, so a pattern that matches happily here can still be rejected elsewhere. In exchange you get named capture groups, the s (dotAll) flag and Unicode property escapes under the u flag, all of which this tool exposes directly.

Nothing you type is uploaded. The pattern and the test string are compiled and matched by your own browser, so production log lines, customer exports and internal fixtures can be pasted here without leaving your machine. Once the expression behaves, the text diff checker shows exactly what your replacement changed, the JSON validator confirms the structure you scraped out still parses, and the case converter normalises casing so a single pattern can cover every variant.

Frequently Asked Questions (FAQ)

What is a regex tester?

A regex tester compiles a regular expression and runs it against sample text so you can see the outcome immediately instead of guessing. This one highlights every match, lists the index and capture groups for each hit, and previews a replace β€” live as you type, with no run button to press.

How do I test a regular expression online for free?

Type your pattern into the field between the two slashes, tick the flags you need, then paste your sample text into the test string box. Matches are highlighted instantly and listed underneath, so there is nothing to install, no account to create and no cost.

Which regex engine does this online regular expression tester use?

It uses the JavaScript RegExp engine built into your browser, which is the same engine Node.js uses. Patterns written for PCRE, Python or .NET mostly transfer, but constructs such as \A, \z, atomic groups and recursion simply do not exist in JavaScript, and lookbehind support varies by browser.

What do the g, i, m, s, u and y regex flags do?

g finds every match instead of stopping at the first, i ignores case, m makes ^ and $ match at the start and end of each line, s lets the dot match newlines, u turns on full Unicode handling, and y anchors each attempt to the position where the previous match ended. Every checkbox in the tool repeats the same one-line reminder so you never have to look it up.

How do I see capture groups and named groups in the results?

Each match row lists its numbered groups in order, so the first pair of parentheses is Group 1. If you name a group with (?<name>...), the named groups appear underneath with their names, and an optional group that did not participate is labelled rather than silently skipped.

How does the regex replace preview work?

The replace box runs String.replace with the pattern you compiled, so the usual substitution tokens apply: $1 and $2 for numbered groups, $<name> for a named group, $& for the whole match and $$ for a literal dollar sign. The result pane updates live and copies in one click.

Is this a good free regex101 alternative?

For fast live matching, capture groups, flags and a replace preview without signing in, yes. This tester stays deliberately small and runs entirely in your browser; it does not ship a step-by-step debugger or non-JavaScript flavours, so reach for a heavier tool when you need a pattern explained token by token.

Are my pattern and test data private?

Yes. Neither the pattern nor the text is sent anywhere β€” everything is compiled and matched by JavaScript running on your own machine. Pasting logs, tokens or customer records here does not put them on a server.

Tips for Testing Regular Expressions

  • Tip 1: Start broad, then tighten. Match too much first, read the highlighted preview, and add anchors, \b word boundaries or a tighter character class until only the text you want stays yellow.
  • Tip 2: Turn the g flag off when you only care about the first hit, and remember that the m flag changes ^ and $ to mean the start and end of each line rather than of the whole string.
  • Tip 3: Avoid nested quantifiers such as (a+)+ or (\w+)*. On a long string that almost matches, they trigger catastrophic backtracking and can freeze a browser or a server β€” rewrite them with a single character class or a non-greedy inner part.
  • Tip 4: Check the input before you match it: the word counter and text analyzer tells you how many lines and words you are dealing with, and the text diff checker proves your replace step changed only what you intended.