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 typeCommon patterns — click to load
Results
Live match resultsEnter 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.
.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^Start of string (or line with m flag)$End of string (or line with m flag)\bWord boundary\BNon-word boundary*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(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 abca|bAlternation — match a or b\.Literal dot\*Literal asterisk\+Literal plus\?Literal question mark\(Literal opening parenthesis\)Literal closing parenthesis\[Literal opening bracket\]Literal closing bracket\\Literal backslash\nNewline\tTabgGlobal — find all matches, not just the firstiIgnore case — case-insensitive matchingmMultiline — ^ and $ match line boundariessDotall — . matches newlines toouUnicode — full Unicode support (e.g. \p{...})ySticky — match only at lastIndexWhat 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
- Enter your pattern in the regular expression input. The leading and trailing slashes are provided for you — just type the pattern itself.
- Select your flags using the chips below the input. The
gflag is on by default so all matches are found. Click any flag to toggle it on or off. - Paste or type your test string in the textarea. Matches will highlight automatically as you type.
- Review the matches in the right panel. Each match shows its index, start position, matched value, and any capture groups or named groups.
- 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. - 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. |
| URL | https?://[^\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]\d | 24-hour time, 00:00 to 23:59. |
| IPv4 address | \b(?:\d{1,3}\.){3}\d{1,3}\b | Basic IPv4. Doesn't validate octet range (0–255). |
| Hex colour | #(?:[0-9a-fA-F]{3}){1,2}\b | Matches #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\b | Finds 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 |
|---|---|---|
g | Global | Find all matches instead of stopping after the first. Without g, exec() returns only the first match. |
i | Ignore case | Makes matching case-insensitive. /hello/i matches "Hello", "HELLO", and "hello". |
m | Multiline | Makes ^ and $ match the start and end of each line, not just the whole string. |
s | Dotall | Makes . match newline characters too. Without s, . stops at line breaks. |
u | Unicode | Enables full Unicode mode. Required for \p{...} property escapes and correct handling of surrogate pairs. |
y | Sticky | Matches 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
^ 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.$1, $2, and $<name> syntax to reference captured groups. The transformed output appears in the results panel.(...) 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.