Digital ToolPad.

Runs 100% in your browser

Your data never leaves your device. zero uploads.

Test, explain and debug regular expressions

Online Regex Tester and Debugger

Type a regular expression, paste your text and see every match highlighted as you type, with capture groups, a replace preview, a plain-English explanation and pass/fail tests. It runs on your browser's JavaScript engine, entirely on your device: nothing is uploaded.

How it works
2 matches2 groups1 ms
161 chars

Uses your browser's JavaScript regex engine. Matching runs in a background thread, so a runaway pattern is stopped instead of freezing the page. Need a pattern from a plain English description? Try Regex AI, also offline

Matches with their position and capture groups
#MatchPosition
1
user
ada.lovelace8-20
domain
example.com21-32
8-32
2
user
support+billing80-95
domain
mail.example.co.uk96-114
80-114

What is a regex tester?

A regex tester is a tool that runs a regular expression against sample text and shows exactly what it matches, so you can fix the pattern before it goes into your code, spreadsheet or search box. Regular expressions are compact and easy to get slightly wrong: a missing escape, a greedy .* or an unanchored validation pattern can pass a quick check and still fail on real data.

This tester highlights each match inside the editor, lists every capture group with its position, previews what a replacement will produce and explains the pattern one token at a time. It uses the JavaScript (ECMAScript) regex engine built into your browser, which follows the same standard as Node.js, Deno and Bun, so what you see here is what new RegExp() will do in your code.

How to test a regex online

  1. 1

    Type the pattern

    Enter the pattern between the slashes, without the surrounding / characters. Pick an entry from Common patterns to start from a working email, URL, date or phone example.

  2. 2

    Set the flags

    Toggle g to find every match, i to ignore case, m to make ^ and $ work per line, s to let the dot match line breaks, u for full Unicode and y for sticky matching.

  3. 3

    Add your text

    Paste sample text or press Open file to load a .txt, .log, .csv or other text file from your device. Matches are highlighted in place, and the status bar shows the count and time taken.

  4. 4

    Check and export

    Review groups in Matches, try a substitution in Replace, read the breakdown in Explain, prove edge cases in Tests and copy ready-made code for six languages. Share copies a link that keeps everything in the URL.

What this regex tester does

Everything happens live as you type, and every panel works without an account or an internet connection once the page has loaded.

Highlighting in the editor
Matches are marked in the text you are editing, in alternating colors so neighboring matches stay distinct. Empty matches show as a thin marker.
Capture and named groups
Each match lists its numbered and named groups with their start and end positions. Select a match to jump to it in the text.
Replace preview
Write a replacement with $1, $<name>, $& and other tokens and see the full result update instantly. Copy it or download it as a text file.
Plain-English explanation
The Explain tab breaks the pattern into tokens such as \d, [A-Z], (?<year>...) and {2,4}, indents nested groups and describes each one in a sentence.
Should match / should not match tests
List valid and invalid inputs, one per line, and see which ones pass. Ideal for checking validation patterns before they reach production.
Code in six languages
Copy a working snippet for JavaScript, Python, PHP, Java, C# or Go. Python and Go named groups are converted, and features an engine lacks are flagged.
Export matches
Copy all matches as a list or download them as CSV or JSON with group columns, ready for a spreadsheet or a script.
Runaway pattern protection
Matching runs in a background Web Worker. If a pattern backtracks for more than 2 seconds, it is stopped and explained instead of freezing the tab.

Regex cheat sheet: characters and classes

These are the building blocks you will use in almost every pattern. The same tokens are in the Cheat sheet tab above, where selecting one inserts it into your pattern.

Regex character classes with meanings and examples
TokenMeaningExample
.Any character except a line break (any at all with the s flag)c.t matches cat, cot, c7t
\dA digit 0 to 9\d{3} matches 404
\wA word character: letter, digit or _\w+ matches user_42
\sWhitespace: space, tab, line breaka\sb matches a b
\D \W \SThe opposite of \d, \w and \s\D+ matches abc in abc123
[abc]One of the listed charactersgr[ae]y matches gray and grey
[^abc]Any character except the listed ones[^0-9] matches a non-digit
[a-z]One character in the range[A-F0-9] matches a hex digit
\.A literal dot. Escape any of . * + ? ^ $ ( ) [ ] { } | \ / to match it3\.14 matches 3.14 only
\p{L}Any letter in any script (needs the u flag)\p{L}+ matches café and Привет

Anchors and quantifiers

Anchors match a position rather than a character, and quantifiers say how many times the previous item may repeat. By default quantifiers are greedy: they take as much text as they can, then give back only what the rest of the pattern needs.

Regex anchors and quantifiers
TokenMeaningExample
^Start of the text, or of each line with the m flag^Hello matches Hello at the start
$End of the text, or of each line with the m flagend$ matches end at the end
\bWord boundary\bcat\b matches cat but not concatenate
\BNot a word boundary\Bcat matches the cat in concatenate
*Zero or more of the previous itemab*c matches ac, abc, abbbc
+One or more\d+ matches 7 and 2026
?Zero or one (optional)colou?r matches color and colour
{3}Exactly 3 times\d{3} matches 123
{2,}2 or more timesa{2,} matches aa and aaaa
{2,4}Between 2 and 4 times\d{2,4} matches 12 and 2026
*? +? ??Lazy versions: match as little as possible<.+?> matches one tag, not the whole line

Groups, backreferences and lookarounds

Groups let you capture part of a match, repeat a sequence or apply alternation to just one section. Lookarounds check what comes before or after a position without including it in the match.

Regex groups, backreferences and lookarounds
TokenMeaningExample
(abc)Capture group, numbered from 1(\d+)-(\d+) captures 10 and 20 in 10-20
(?<name>abc)Named capture group(?<year>\d{4}) captures year
(?:abc)Group without capturing(?:ab)+ matches abab
a|bAlternation: a or bcat|dog matches either word
\1Backreference to group 1(\w)\1 matches ll in hello
\k<name>Backreference to a named group(?<q>['"]).*?\k<q> matches a quoted string
(?=abc)Lookahead: followed by abc\d+(?=px) matches 12 in 12px
(?!abc)Negative lookahead: not followed by abc\d+(?!px) skips numbers before px
(?<=abc)Lookbehind: preceded by abc(?<=\$)\d+ matches 5 in $5
(?<!abc)Negative lookbehind: not preceded by abc(?<!-)\b\d+ skips negative numbers

Regex flags explained

Flags change how the whole pattern behaves. In JavaScript they follow the closing slash, as in /cat/gi, or go in the second argument of new RegExp("cat", "gi").

JavaScript regex flags
FlagNameWhat it does
gglobalFinds every match instead of stopping at the first. Needed for matchAll and replace-all behavior.
iignoreCaseTreats upper and lower case as the same, so /cat/i matches Cat and CAT.
mmultilineMakes ^ and $ match at the start and end of every line, not only the whole text.
sdotAllLets . match line breaks too. Without it, .* stops at the end of a line.
uunicodeReads the pattern as Unicode code points, enables \p{...} and \u{...} and rejects invalid escapes.
ystickyMatches only at the current lastIndex position, which is handy for tokenizers.
dhasIndicesAdds start and end positions for each group. This tester uses it to show group positions.
vunicodeSetsA stricter upgrade of u that adds set operations inside classes. Supported in current browsers.

Regex replacement syntax

In a JavaScript replacement string, a dollar sign followed by a number or name inserts captured text. To swap first and last names, match (\w+) (\w+) and replace with $2, $1.

Replacement tokens for String.replace
TokenMeaningExample
$1Text captured by group 1(\w+) (\w+) with $2 $1 swaps two words
$<name>Text captured by a named group$<year> inserts the year group
$&The whole match[$&] wraps each match in brackets
$`Text before the matchRarely needed; useful for debugging
$'Text after the matchRarely needed; useful for debugging
$$A literal dollar sign$$$1 turns 5 into $5

Common regex patterns you can copy

Each of these is in the Common patterns menu with sample text and ready-made tests. Patterns for emails and URLs are deliberately practical rather than complete: the full specifications allow strings you rarely want to accept.

Common regular expressions
PatternRegexNotes
Email address[\w.+-]+@[\w-]+(?:\.[\w-]+)*\.[A-Za-z]{2,}Practical check for the usual name@domain.tld shape. Full RFC 5322 validation is far longer; confirm real addresses by sending an email.
URL (http and https)https?:\/\/[\w-]+(?:\.[\w-]+)+(?::\d+)?(?:\/[^\s]*)?Finds web links in running text. Trailing punctuation such as a full stop can end up in the match.
IPv4 address\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\bEach part is limited to 0 to 255.
Date (YYYY-MM-DD)\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\bNamed groups for year, month and day. It does not know month lengths, so 2026-02-31 still matches.
Time (24-hour HH:MM)\b(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?\bSeconds are optional.
US phone number(?:\+1[\s.-]?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}\bAccepts common US formats with spaces, dots, dashes or brackets.
International phone (E.164)^\+[1-9]\d{6,14}$E.164 is a plus sign and up to 15 digits with no spaces. Uses the m flag to test each line.
Hex color#(?:[0-9a-fA-F]{3}){1,2}\bMatches 3 and 6 digit CSS hex colors.
UUID\b[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\bVersions 1 to 8 with the standard variant bits.
URL slug^[a-z0-9]+(?:-[a-z0-9]+)*$Lowercase words joined by single hyphens.
Strong password^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{12,}$Lookaheads require a lowercase letter, an uppercase letter, a digit and a symbol, with at least 12 characters.

JavaScript vs Python vs PCRE vs Go regex

Regex syntax is mostly shared, but engines differ in the details. If a pattern works here and fails elsewhere, one of these is usually the reason. The Code tab converts named groups for Python and Go and warns about unsupported features.

Regex feature support by engine
FeatureJavaScriptPython rePCRE (PHP)Go (RE2)
Named groups(?<name>...)(?P<name>...)(?<name>...) or (?P<name>...)(?P<name>...), and (?<name>...) since Go 1.22
LookbehindYes, any lengthFixed length onlyYes, length limits applyNo
BackreferencesYesYesYesNo
Unicode classes like \p{L}Yes, with the u or v flagNo (third-party regex module only)YesYes
Atomic groups and possessive quantifiersNoYes, since Python 3.11YesNo
Catastrophic backtrackingPossiblePossiblePossible, with backtrack limitsNot possible: matching runs in linear time

Why does my regex freeze or time out?

A regex freezes when it backtracks catastrophically: the engine tries an exponential number of ways to split the text before it can report that there is no match. The classic example is ^(a+)+$ against a long run of a characters followed by a b. Each extra character roughly doubles the work, so 30 characters can take seconds and 40 can take minutes.

Most browser-based testers run the pattern on the page's main thread, so the whole tab locks up. Here matching runs in a background Web Worker and is stopped after 2 seconds with a warning. To fix the pattern, remove nested quantifiers like (a+)+ or (.*)*, use specific classes such as [^,]* instead of .*, and anchor patterns that should match a whole value.

Common regex mistakes

  • Forgetting to escape a dot: 3.14 also matches 3x14. Write 3\.14.
  • Using ^ and $ on multi-line text without the m flag, so they only match at the very start and end.
  • Expecting .* to cross line breaks. Turn on the s flag or use [\s\S]*.
  • Writing [A-z] for letters. It also matches [ \ ] ^ _ and the backtick. Use [A-Za-z].
  • Validating with an unanchored pattern, so \d{5} accepts 123456789. Use ^\d{5}$ or the Whole line test mode.
  • Calling test() repeatedly on a regex with the g flag. It remembers lastIndex between calls and can return true, then false, on the same string.
  • Forgetting that a regex in a string literal needs double backslashes: "\\d+" in code is \d+ in the pattern. The Code tab writes this for you.

How this tester compares with regex101 and RegExr

regex101 and RegExr are excellent and worth knowing. This tester is built for the common case: JavaScript-compatible patterns, tested quickly and privately.

Regex tester comparison
FeatureThis testerregex101RegExr
Regex enginesJavaScript (your browser)Several, including PCRE2, JavaScript, Python, Java, .NET and GoJavaScript and PCRE
SharingLink keeps the state after #, so it is never sent to a serverSaves the pattern on regex101 to create a linkSaves the pattern on RegExr to create a link
Pass/fail testsShould match and should not match listsUnit testsTests panel
Code exportJavaScript, Python, PHP, Java, C#, GoCode generator for many languagesNot built in
AccountNoneOptionalOptional

Common uses for a regex tester

  • Validating form input such as emails, phone numbers, postcodes and passwords before shipping the pattern.
  • Pulling values out of logs: status codes, IP addresses, request IDs and timestamps.
  • Planning a find and replace across a codebase in VS Code, JetBrains IDEs, sed or a spreadsheet.
  • Cleaning data: trimming trailing spaces, normalizing dates or removing duplicate words.
  • Writing routing rules, redirects, linters and search filters that take a regex.
  • Learning regex: change one token at a time and watch the highlights and the explanation update.

Why test your regex here

Private by design
Patterns, text and files are processed in your browser. Nothing is uploaded, which matters when the sample is a production log or customer data.
Fast on large text
Matching runs off the main thread, so typing stays smooth with long logs, and you get a clear warning instead of a frozen tab.
No account, no install
Open the page on Windows, Mac, Linux, a Chromebook or a phone and start testing. It keeps working offline once loaded.
From test to code
Tests, replacement preview and copy-ready code mean the pattern you checked is the pattern you ship.

Regex tester FAQ

Is this regex tester free and private?

Yes. It is free with no sign-up, and every match, replacement and test runs in your browser. Your pattern, text and opened files are never sent to a server. Share links store the state after the # in the URL, which browsers do not send to servers.

Which regex flavor does this tester use?

It uses the JavaScript (ECMAScript) engine in your browser, the same regex standard that Node.js and front-end code use. Most everyday syntax also works in Python, PHP, Java, C# and Go, but named groups, lookbehind, Unicode classes and backreferences differ. The flavor table and the Code tab show the differences.

How do I check that a whole string matches, not just part of it?

Anchor the pattern with ^ at the start and $ at the end, for example ^\d{5}$ for a five-digit code. In the Tests tab, Whole line must match does this for you, so 123456 fails a \d{5} pattern instead of passing because it contains five digits.

How do I match across multiple lines?

Turn on the m flag if you want ^ and $ to match at each line. Turn on the s flag if you want the dot to match line breaks, so .* can span several lines. Without s, use [\s\S]* to match anything including new lines.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers such as .* and .+ take as much text as possible. Lazy versions such as .*? and .+? take as little as possible. Against <b>one</b> <b>two</b>, <b>.*</b> matches the whole line, while <b>.*?</b> matches each bold tag separately.

Why does my regex return true, then false, with the g flag?

A regex with the g or y flag keeps a lastIndex position between calls to test() and exec(). The second call starts searching where the first match ended, so it can miss. Drop the g flag for yes/no checks, or reset regex.lastIndex = 0 before each test.

Can I test a regex against a log or text file?

Yes. Press Open file and choose a .txt, .log, .csv, .json or other text file up to 5 MB. It is read locally into the editor, and you can export the matches as CSV or JSON afterwards.

100% private: your data never leaves your browser

No registration, no tracking of your content, no server uploads. Don't just take our word for it:

  • No server, no uploads

    Your files and text are processed entirely on your device. Nothing is ever sent to us.

  • Works offline

    Once loaded, this tool keeps working with your Wi-Fi turned off. Try it.

  • Verify it yourself

    Open your browser's DevTools → Network tab. You'll see zero requests carrying your data.

Explore more tools

More utilities for your next task.

Browse all tools