Regex Tester
Last updated:
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.
For freelancers & agencies
Have a client who needs a better website or help getting found?
Introduce them to Web Aloha. We handle the proposal, delivery and support directly with your client.
Have a client who needs a better website or help getting found?
Introduce them to Web Aloha. We handle the proposal, delivery and support directly with your client.
One-off projects: 10%, with a $100 minimum.
Monthly retainers: 10% each month for the first six months.
More options Send us this result or get a copy by email
Refer a Client, Earn a Reward
Introduce a client who needs a website or help getting found. We handle the proposal, delivery and support directly with your client. One-off projects pay 10%, with a $100 minimum. Monthly retainers pay 10% each month for the first six months.
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.
Next steps
Regex Tester related tools and articles
Continue with the closest follow-up checks and guides based on this tool's topic, crawl intent, and optimization workflow.