Regex Tester

Last updated:

Write a regular expression and test it against your text in real time. See highlighted matches, capture groups, and replace output, with every flag at your fingertips, all running privately in your browser.

/ /
0 matches

JavaScript regex engine. Runs entirely in your browser.

Refer a Client, Earn 10% or $100

Use our tools for client work? When a client needs a website, SEO, or AI-search visibility, send them our way and earn 10% or $100, whichever is greater.

How to Use the Regex Tester

  1. Enter a pattern, type your regular expression between the slashes.
  2. Set flags, toggle global, case-insensitive, multiline, and more.
  3. Add test text, matches highlight live as you type.
  4. Inspect groups and replace, review capture groups and preview replacements.

Regex Quick Reference

  • \d digit, \w word char, \s whitespace, . any char.
  • * zero or more, + one or more, ? optional, {n,m} range.
  • ^ start, $ end, \b word boundary.
  • (...) capture group, (?<name>...) named group, (?:...) non-capturing.
  • [abc] character set, [^abc] negated set, a|b alternation.

Regex Cheat Sheet

A reference for the regular expression tokens you will use most often. Examples use JavaScript (ECMAScript) syntax, the same engine this tester runs. Paste any example into the pattern field above to see it match.

Character classes

TokenMatchesExample
.Any character except a line break (any character including newlines with the s flag)a.c matches "abc", "a c"
\dAny digit, 0 to 9\d\d matches "42"
\DAny non-digit character\D matches "a", "-"
\wAny word character: letters, digits, or underscore ([A-Za-z0-9_])\w+ matches "user_1"
\WAny non-word character\W matches "!", " "
\sAny whitespace: space, tab, newline\s matches " ", a tab
\SAny non-whitespace character\S+ matches "word"
[abc]Any one of the listed characters; ranges allowed with -[a-f] matches "c"
[^abc]Any single character not listed (negated class)[^0-9] matches "x"
\.A literal dot; backslash escapes any special character\. matches "." only

Anchors and boundaries

TokenMatchesExample
^Start of the string (or start of each line with the m flag)^Hi matches "Hi there"
$End of the string (or end of each line with the m flag)end$ matches "the end"
\bA word boundary (position between \w and non-\w)\bcat\b matches "cat" not "category"
\BA non-word-boundary position\Bcat matches "cat" in "scatter"

Quantifiers

TokenMatchesExample
*Zero or more of the preceding token (greedy)ab* matches "a", "abbb"
+One or more of the preceding token (greedy)\d+ matches "2026"
?Zero or one of the preceding token (optional)colou?r matches "color", "colour"
{n}Exactly n of the preceding token\d{4} matches "2026"
{n,m}Between n and m of the preceding token; {n,} means n or more\d{2,4} matches "12" to "1234"
*? +?Lazy versions: match as few as possible<.*?> matches one tag, not all

Groups and alternation

TokenMatchesExample
(...)Capturing group; stores the match as $1, $2, and so on(\d{4})-(\d{2}) captures year and month
(?:...)Non-capturing group; groups without storing a reference(?:ab)+ matches "abab"
(?<name>...)Named capturing group, referenced by name(?<y>\d{4}) captures as "y"
|Alternation: match the expression before or after itcat|dog matches "cat" or "dog"

Flags

FlagEffect
gGlobal: find all matches, not just the first
iCase-insensitive matching
mMultiline: ^ and $ match line starts and ends
sDotall: . also matches newline characters
uUnicode: treat the pattern as Unicode code points
ySticky: match only at the current lastIndex position

Regular expressions power validation, search, and data cleanup across almost every codebase. If you would rather offload tricky parsing, scraping, or data-transformation work, our team builds and maintains it as part of our web design and development services.

Next steps

Regex Tester related tools and articles

Continue with the closest follow-up checks and guides based on this tool's topic, crawl intent, and optimization workflow.

Regex Tester: FAQ

Which regular-expression engine does this tester use?
It uses the JavaScript RegExp engine in your current browser. The available syntax therefore follows that browser's ECMAScript support, which can differ from PCRE, Python, .NET, RE2, or an older JavaScript runtime.
How do the g, i, m, s, and u controls affect the preview?
The g flag shows all matches; without it the tool stops after the first. The i flag ignores case, m changes how line anchors work, s lets dot match line breaks, and u enables Unicode-aware pattern parsing. You can also type flags directly, and invalid combinations produce an error.
Why are capture groups shown only once?
The group panel displays numbered and named groups from the first match so the layout stays readable. The highlight and match count still cover every match when g is enabled. Inspect later groups in your application if captures vary by match.
How does the replacement preview handle group references?
The preview uses JavaScript String.replace. Use $1 and $2 for numbered groups, $<name> for a named group, and $& for the complete match. Without the g flag, only the first match is replaced.
Why does the tool say preview skipped?
The live preview stops when the pattern exceeds 500 characters, the test text exceeds 20,000 characters, or a heuristic detects nested repetition or repeated wildcards that may cause catastrophic backtracking. Simplify the pattern or test a smaller representative sample.
What does an invalid result mean?
The browser could not construct a RegExp from the pattern and flags. Read the displayed engine message, then check unbalanced brackets, unsupported syntax, incomplete escapes, or duplicate flags. The tool clears groups and replacement output until the pattern compiles.
How are empty-string matches handled?
Patterns such as ^, $, or a zero-width lookaround can match a position without consuming text. The preview manually advances after a zero-length match to avoid an infinite loop, so test boundary-heavy patterns again in the exact runtime where you will deploy them.
Are my pattern, sample text, and replacement uploaded?
No. Pattern compilation, matching, highlighting, and replacement all run in your browser. The entered pattern and text are not sent to a Web Aloha API or saved by this tool.

Need Custom Tools or Automation?

From data cleanup to bespoke web apps, we build fast, reliable tooling that saves your team hours.