Regex Tester
Last updated: What’s new
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.
JavaScript regex engine. Runs entirely in your browser.
Referral reward
Know a business that needs a website or SEO?
Introduce them and earn a referral reward. They work with us directly, and we handle the proposal, delivery and support.
Know a business that needs a website or SEO?
Introduce them and earn a referral reward. They work with us directly, and we handle the proposal, delivery and support.
Projects: 10%, at least $100
Monthly services: 10% for the first six months
A $1,999 website earns you about $200. A $999 a month SEO plan earns about $600 over six months.
Your introduction message
This reference credits the introduction to you:
Email me the referral details
More options Send us this result or get a copy by email
Know a business that needs a website or SEO?
Introduce them and earn a referral reward. They work with us directly.
- Projects: 10%, at least $100
- Monthly services: 10% for the first six months
Your introduction message
This reference credits the introduction to you:
Email me the referral details
How to Use the Regex Tester
- Enter a pattern, type your regular expression between the slashes.
- Set flags, toggle global, case-insensitive, multiline, and more.
- Add test text, matches highlight live as you type.
- Inspect groups and replace, review capture groups and preview replacements.
Regex Quick Reference
\ddigit,\wword char,\swhitespace,.any char.*zero or more,+one or more,?optional,{n,m}range.^start,$end,\bword boundary.(...)capture group,(?<name>...)named group,(?:...)non-capturing.[abc]character set,[^abc]negated set,a|balternation.
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
| Token | Matches | Example |
|---|---|---|
. | Any character except a line break (any character including newlines with the s flag) | a.c matches "abc", "a c" |
\d | Any digit, 0 to 9 | \d\d matches "42" |
\D | Any non-digit character | \D matches "a", "-" |
\w | Any word character: letters, digits, or underscore ([A-Za-z0-9_]) | \w+ matches "user_1" |
\W | Any non-word character | \W matches "!", " " |
\s | Any whitespace: space, tab, newline | \s matches " ", a tab |
\S | Any 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
| Token | Matches | Example |
|---|---|---|
^ | 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" |
\b | A word boundary (position between \w and non-\w) | \bcat\b matches "cat" not "category" |
\B | A non-word-boundary position | \Bcat matches "cat" in "scatter" |
Quantifiers
| Token | Matches | Example |
|---|---|---|
* | 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
| Token | Matches | Example |
|---|---|---|
(...) | 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 it | cat|dog matches "cat" or "dog" |
Flags
| Flag | Effect |
|---|---|
g | Global: find all matches, not just the first |
i | Case-insensitive matching |
m | Multiline: ^ and $ match line starts and ends |
s | Dotall: . also matches newline characters |
u | Unicode: treat the pattern as Unicode code points |
y | Sticky: 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.
What’s new
-
An empty replacement now previews the text with the matches removed instead of an empty result.
-
Live previews run in a cancellable local worker, with a time limit and recovery for slow expressions.
Next steps
Regex Tester related tools and articles
The closest follow-up checks and guides for this tool.