Regex Tester
Test and debug regular expressions with live match highlighting, flag toggles, and a full match list. Supports all JavaScript regex flags - g, i, m, s, u, and y.
Enter a pattern and test string above
Or choose a sample to get started instantly
Features
Everything you need, nothing you don’t.
- Live match highlighting as you type - no submit button needed
- Toggle flags individually: g (global), i (case insensitive), m (multiline), s (dot all), u (unicode), y (sticky)
- Detailed match list with index position and named group values
- Copy the full regex literal to clipboard with one click
- Built-in samples for email, URL, IP address, and hex color patterns
- Invalid regex errors are shown immediately with the engine's exact message
Related Tools
-
Regex Cheat Sheet
Quick reference for regex tokens, quantifiers, groups, and assertions.
Regex -
JSON Formatter
Format, validate, and pretty-print JSON with error detection.
Format & Convert -
JWT Decoder
Decode and inspect JSON Web Token claims without a secret.
Auth & IDs -
URL Encoder
Percent-encode special characters for safe use in URLs.
Encoding
Frequently asked questions
How do I use the Regex Tester?
Enter your pattern in the top input field - without the surrounding slashes. Toggle any flags you need using the flag buttons below. Then type or paste your test string in the text area. Matches are highlighted in real time and listed below with their index positions.
What regex flavor does this tool use?
This tool uses JavaScript's built-in RegExp engine, which runs entirely in your browser. It supports ES2018+ features including named capture groups ((?<name>...)), lookbehinds ((?<=...) and (?<!...)), the s (dotAll) flag, and the u (unicode) flag. PCRE-specific syntax like \K, atomic groups, or possessive quantifiers is not supported.
What does the g (global) flag do?
The g flag tells the engine to find all matches in the test string rather than stopping after the first. Without g, only the first match is returned. The Regex Tester always searches globally for highlighting purposes - the flag setting affects the copied regex literal.
What is the difference between m (multiline) and s (dotAll)?
The m flag changes how ^ and $ work: with m, they match the start and end of each line rather than the entire string. The s flag changes how . works: by default . does not match newline characters (\n), but with s it matches any character including newlines. These two flags are independent and can be combined.
Why does my regex return unexpected matches?
Common causes: the g flag is missing so only the first match is found; the i flag is absent so case is not ignored; anchors like ^ or $ are behaving per-string rather than per-line (try adding m); or . is not matching newlines (try adding s). Also check for unescaped metacharacters - in a regex, . + * ? ( ) [ ] { } ^ $ | \ must be escaped with a backslash to match literally.
How do I match a literal dot or other special character?
Escape the character with a backslash. For example, to match a literal dot write \. - without the backslash, . matches any character. The full set of metacharacters that must be escaped when used literally are: \ ^ $ . | ? * + ( ) [ ] { }
What are named capture groups and how do I use them?
Named capture groups let you label a capturing group so you can reference it by name instead of index. Syntax: (?<name>pattern). For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) matches an ISO date and exposes match.groups.year, match.groups.month, and match.groups.day. The Regex Tester shows named group values alongside each match.