๐Ÿงช Regex Tester

//g
Contact: alice@example.com or bob@test.org
Matches (2)
#0 @9alice@example.com
#1 @30bob@test.org

Test a regular expression against a string in real time, with matches highlighted. Great for checking how a complex pattern actually behaves โ€” for example, validating a form field or checking a log-parsing pattern.

How to use

  1. Enter your regular expression in the "Pattern" field.
  2. Enter the text you want to test against in the "Test String" field.
  3. Matches are highlighted in real time, and you can review the full list of matches.

How the calculation works

A regular expression describes a pattern of text using special symbols. This tool uses JavaScript's (ECMAScript's) regex engine, so it is well suited to checking patterns you will use in JavaScript. Other languages โ€” Perl, Python, PHP and so on โ€” differ in some of the syntax they support. Common symbols: "." matches any character, "*" zero or more of the previous item, "+" one or more, "?" zero or one, "[a-z]" a character range, and "^" and "$" the start and end of a line or string. Parentheses create capture groups, letting you extract the matched parts individually. Flags modify how the pattern behaves: "g" finds every match, "i" ignores case, and "m" makes ^ and $ match at the start and end of each line.

Worked example

Testing a pattern to extract dates Pattern: (\d{4})-(\d{2})-(\d{2}) Test string: from 2026-09-18 to 2026-10-01 Flag: g Both dates match, and each capture group gives the year, month and day separately, such as "2026", "09" and "18". Note that this tool always lists every match, so it adds the g flag automatically even if you leave it out. In your own code, the same pattern without g would match only the first date, 2026-09-18.

Things to be aware of

  • Patterns run with JavaScript regex syntax; results may differ in other languages.
  • Nested repetition such as "(a+)+" can become catastrophically slow on certain inputs (ReDoS).
  • Fully validating something like an email address with a regex alone is very hard; in practice people check only that the format is roughly right.
  • The number of backslashes differs between typing a pattern here and writing it as a string literal in code.

FAQ

Which regex flavor is supported?

JavaScript (ECMAScript) regular expression syntax.

What happens if there's no match?

It clearly indicates no matches were found, which helps you spot issues in your pattern or test string.

Can I check multiple matches with the global flag?

Yes โ€” if your pattern matches multiple places in the text, every match is highlighted and listed.

Can I see the contents of capture groups?

Yes โ€” if your pattern includes capture groups in parentheses, the match results list shows the value captured by each group.

Can I test an email or phone number validation pattern?

Yes โ€” it's well suited to checking whether a regex you wrote for form validation behaves as intended against a variety of test strings.