Regex Tester

Test regular expressions instantly in your browser. Write a pattern, paste a test string, and see live match highlighting, capture groups, named groups, and positions — plus replace mode and a full syntax cheat sheet. Free, private, and supports every JavaScript regex flag.

Pattern & Test String

Matches update live as you type
/ g

Common patterns — click to load

Results

Live match results

Enter a pattern on the left. Matches will highlight below in real time.

Regex cheat sheet

A quick reference for the most common JavaScript regex tokens. Click any pattern above to load it into the tester, or read through this list to refresh your memory.

Character classes
.Any character except newline (with s flag: any character)
\dDigit (0–9)
\DNon-digit
\wWord character (a–z, A–Z, 0–9, _)
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Any of a, b, or c
[^abc]Any character except a, b, or c
[a-z]Character range: a through z
Anchors & boundaries
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary
Quantifiers
*Zero or more
+One or more
?Zero or one (optional)
{3}Exactly 3 times
{2,5}Between 2 and 5 times
{2,}At least 2 times
*?Lazy: zero or more, as few as possible
+?Lazy: one or more, as few as possible
??Lazy: zero or one, prefer zero
Groups & backreferences
(abc)Capture group — captures the matched text
(?:abc)Non-capturing group — groups without capturing
(?<name>abc)Named capture group
\1Backreference to capture group 1
\k<name>Backreference to named group
(?=abc)Positive lookahead — followed by abc
(?!abc)Negative lookahead — not followed by abc
(?<=abc)Positive lookbehind — preceded by abc
(?<!abc)Negative lookbehind — not preceded by abc
a|bAlternation — match a or b
Escape sequences
\.Literal dot
\*Literal asterisk
\+Literal plus
\?Literal question mark
\(Literal opening parenthesis
\)Literal closing parenthesis
\[Literal opening bracket
\]Literal closing bracket
\\Literal backslash
\nNewline
\tTab
Flags
gGlobal — find all matches, not just the first
iIgnore case — case-insensitive matching
mMultiline — ^ and $ match line boundaries
sDotall — . matches newlines too
uUnicode — full Unicode support (e.g. \p{...})
ySticky — match only at lastIndex

What does this Regex Tester do?

A regex tester is a development tool that lets you write a regular expression, run it against a test string, and see the results immediately. Instead of guessing whether your pattern works, you get live feedback: every match is highlighted in the test string, and each match's position, length, and capture groups are shown in a structured list.

This tool uses the JavaScript regex engine (ECMAScript), which is the same engine used in browsers and Node.js. If your pattern works here, it will work in your JavaScript code. It supports the full modern feature set: named capture groups, lookbehind assertions, Unicode property escapes, sticky matching, and all six regex flags (g, i, m, s, u, y).

Everything runs locally in your browser — the pattern and test string never leave your device. No signup, no server round-trip, no logging. The results update live as you type, so you can iterate on a pattern without pressing a button.

How to use the Regex Tester

  1. Enter your pattern in the regular expression input. The leading and trailing slashes are provided for you — just type the pattern itself.
  2. Select your flags using the chips below the input. The g flag is on by default so all matches are found. Click any flag to toggle it on or off.
  3. Paste or type your test string in the textarea. Matches will highlight automatically as you type.
  4. Review the matches in the right panel. Each match shows its index, start position, matched value, and any capture groups or named groups.
  5. Switch to Replace mode if you want to test a replacement. Enter the replacement string (using $1, $2, or $<name> for groups) and see the transformed output.
  6. Load a common pattern from the chips at the bottom of the input panel if you need a starting point.

Why use this Regex Tester?

Live match highlighting

Every match is highlighted in the test string as you type. No button, no page reload — just instant feedback.

Full group details

See every numbered capture group and named group for each match, along with its value and position in the string.

Replace mode

Test regex replacements with $1, $2, and $<name> syntax. See the transformed output instantly.

All six JS flags

Toggle g, i, m, s, u, and y individually. The active flags are shown right in the input.

Common patterns library

A curated set of ready-to-use patterns for emails, URLs, phone numbers, dates, IPs, and more — one click to load.

100% private

Everything runs in your browser. Your pattern and test string never leave your device — no server, no logs.

Common regex patterns you can test

These are the patterns most developers reach for again and again. Click any of the chips in the tool above to load them instantly, or copy the pattern from this table.

What it matches Pattern Notes
Email address[\w.+-]+@[\w-]+\.[\w.-]+Simple, practical email matcher. Doesn't enforce every RFC rule.
URLhttps?://[^\s/$.?#].[^\s]*Matches http and https URLs. Stops at whitespace.
Phone (US)\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}Matches (555) 123-4567, 555-123-4567, 5551234567.
Date (YYYY-MM-DD)\d{4}-\d{2}-\d{2}ISO 8601 date format.
Time (HH:MM)([01]?\d|2[0-3]):[0-5]\d24-hour time, 00:00 to 23:59.
IPv4 address\b(?:\d{1,3}\.){3}\d{1,3}\bBasic IPv4. Doesn't validate octet range (0–255).
Hex colour#(?:[0-9a-fA-F]{3}){1,2}\bMatches #fff and #ffffff.
HTML tag<\/?[a-z][^>]*>Matches opening and closing tags. Not suitable for parsing nested HTML.
Hashtag#\w+Matches #example, #regex_tester.
Mention@\w+Matches @username, @textify.
Number (integer)-?\d+Optional minus sign, then digits.
Number (decimal)-?\d+(\.\d+)?Optional decimal part.
Password (strong)(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}At least one lowercase, one uppercase, one digit, 8+ characters.
Duplicate words\b(\w+)\s+\1\bFinds repeated consecutive words using a backreference.
Trailing whitespace[ \t]+$With m flag, matches trailing spaces on each line.

A note on HTML parsing: regex is not the right tool for parsing nested HTML or XML. For simple cases like extracting attribute values or matching a known tag pattern, it works fine. For anything with nested structures, use a proper parser (like DOMParser in the browser or a server-side HTML parser).

The six JavaScript regex flags

Flags modify how a regular expression behaves. They're written after the closing slash — for example, /pattern/gi. You can combine any flags, and this tool lets you toggle each one independently.

Flag Name What it does
gGlobalFind all matches instead of stopping after the first. Without g, exec() returns only the first match.
iIgnore caseMakes matching case-insensitive. /hello/i matches "Hello", "HELLO", and "hello".
mMultilineMakes ^ and $ match the start and end of each line, not just the whole string.
sDotallMakes . match newline characters too. Without s, . stops at line breaks.
uUnicodeEnables full Unicode mode. Required for \p{...} property escapes and correct handling of surrogate pairs.
yStickyMatches only at the position indicated by lastIndex. Useful for tokenizing input sequentially.

Who uses a regex tester?

Web developers and software engineers

  • Debugging input validation patterns before shipping them
  • Testing URL routing and path matching rules
  • Building form validation for emails, phone numbers, and passwords
  • Writing find-and-replace rules for code refactoring

Data analysts and scientists

  • Extracting structured data from messy text logs
  • Cleaning and normalising CSV or JSON content
  • Validating data formats before ingestion
  • Building parsing rules for semi-structured text

DevOps and system administrators

  • Writing patterns for log filtering and alerting
  • Configuring nginx, Apache, or other server-side regex rules
  • Building grep and awk expressions
  • Filtering output from command-line tools

Technical writers and editors

  • Finding and replacing inconsistent formatting
  • Checking style guide compliance with pattern rules
  • Extracting quotes, headings, and code blocks from documents
  • Validating links and references

Frequently asked questions

A regex tester is an online tool that lets you write a regular expression, run it against a test string, and see the results immediately. It highlights matches, shows capture groups, reports positions, and helps you debug and refine your pattern before using it in code.
This tool uses JavaScript regular expressions (ECMAScript flavor), which is the same engine used in browsers and Node.js. It supports lookahead, lookbehind, named groups, Unicode properties, and all standard JavaScript regex flags. If your pattern works here, it will work in your JavaScript code.
g (global) finds all matches instead of stopping at the first. i (ignore case) makes matching case-insensitive. m (multiline) makes ^ and $ match the start and end of each line. s (dotall) makes . match newlines too. u (unicode) enables full Unicode mode. y (sticky) matches only at the current position.
Yes. The tool shows all numbered capture groups and named capture groups for each match, along with their values and positions in the string. If a group didn't participate in the match (for example, an optional group that wasn't matched), it's shown as undefined.
Yes. You can enter a replacement string and see the result of the regex replacement. The replacement string can use $1, $2, and $<name> syntax to reference captured groups. The transformed output appears in the results panel.
Catastrophic backtracking can make some regex patterns extremely slow. This happens when a pattern has nested quantifiers that can match the same text in many different ways. If your pattern freezes the page, simplify it or use more specific quantifiers. This tool caps the number of matches to protect your browser, but pathological patterns can still be slow.
A capture group (...) stores the matched text so you can reference it later with backreferences or in replacement strings. A non-capturing group (?:...) groups parts of a pattern without storing the match. Non-capturing groups are faster and don't affect the numbering of other groups, so use them when you just need grouping for quantifiers or alternation.
Absolutely. Everything runs in your browser. The pattern and test string you enter never leave your device — no server processing, no logging, no data storage. Close the tab and it's gone.
Yes. The tool is fully responsive and works on phones, tablets, and desktops. The regex input uses a monospace font and disables autocorrect and autocapitalisation so your patterns don't get mangled.
Yes. Once the page loads, the regex tester keeps working even without an internet connection. All pattern matching happens on your device.