↑

Free Regex Tester

What this tool does

The Regex Tester runs your regular expression against any text with live highlighting, so you can see exactly what matches. It lists every match with its position and capture groups, supports the g, i, m and s flags, and can replace matches using group references like $1. Presets cover email, URL, phone, IP, date and hex color patterns. Free, private and instant in your browser, with no signup.


Flags
Common patterns


-
Matches
-
Capture groups
-
First match at
-
Pattern valid
Highlighted text
-
Matches and groups
-
After replace
-
JavaScript regex engine. Use $1, $2 in the replace box for capture groups.

Let us know

Please share your experience with this tool.

Thanks for rating!
No ratings yet — be the first!

How do I test a regular expression?

Type your pattern, paste test text, and matches are highlighted instantly. The stats show how many matches were found, how many capture groups the pattern has, and where the first match starts. The built-in sample uses the email pattern [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,} on a short contact text and finds 2 matches: support@fasttoolkit.com at index 14 and sales@example.org. Each match is listed with its capture groups ($1, $2 and so on), and the highlighted view shows matches in context so you can spot over-matching at a glance. Flags are checkboxes: g finds all matches instead of just the first, i ignores case, m makes ^ and $ match line starts and ends, and s lets the dot match newlines.

What are capture groups and how do I use them?

Parentheses in a pattern capture the part they match. The date pattern (\d{4})-(\d{2})-(\d{2}) has three groups: year, month and day. On the text 2026-11-28 it matches the whole date, with $1=2026, $2=11 and $3=28. Groups are listed under every match in this tester, so you can verify each piece before using it in code. In the replace box, $1, $2 and $3 refer back to the groups, which turns 2026-11-28 into 28/11/2026 with the replacement $3/$2/$1. Non-capturing groups (?:...) group without capturing, useful for alternation like (?:cat|dog) when you do not need the captured value.

What are the most useful regex patterns?

The preset buttons cover the patterns people reach for most. Email: [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}. URL: https?://[^\s]+. International phone: \+?\d[\d\s-]{7,}\d. IPv4 address: \b(?:\d{1,3}\.){3}\d{1,3}\b. Date: \d{4}-\d{2}-\d{2}. Hex color: #(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b. Numbers with optional decimals: -?\d+(\.\d+)?. Words of five or more letters: \b[A-Za-z]{5,}\b. Load any preset, paste your own text, and adjust: most real-world patterns start from one of these and add anchors (^ and $) or stricter character classes for validation.

How does find and replace work here?

Type replacement text and the "After replace" box shows the full result live. Plain text replaces each match, and $1, $2 references insert captured groups, so you can reformat dates, swap name order, or mask sensitive data. The sample replaces both email addresses with [email] while leaving the URL and phone numbers untouched. With the g flag on, every match is replaced; without it, only the first. Replace is also the quickest way to test a pattern intended for a code editor or a script: if the replaced output looks right here, the same pattern and replacement will behave the same in JavaScript, and very similarly in most other languages.

Why is my pattern invalid or matching too much?

Invalid patterns usually come from an unclosed bracket, parenthesis or brace; this tester shows the engine error so you can find the spot. Over-matching usually comes from greedy quantifiers: .* grabs as much as possible, so <.*> on a line with two tags matches from the first < to the last >. Use lazy quantifiers (.*?) or negated classes ([^>]* ) to stop early. Remember that the dot does not match newlines unless the s flag is on, that ^ and $ match the whole text unless m is on, and that special characters like . + * ? ( ) [ ] { } ^ $ | and \ must be escaped with a backslash when you mean them literally, as in \. for a real dot.

Is it free and private?

Yes. The regex tester is free, with no signup, no account and no limits. Patterns and test text are processed entirely in your browser with the JavaScript regex engine, so nothing is sent to a server, stored or logged, and everything disappears when you clear the fields or close the tab. That matters when your test text contains real logs, emails or customer data. For developers, data analysts, SEO specialists and students who need a pattern checked, explained by its matches, or turned into a replace operation, this page does the job in seconds.

FAQs

What does the g flag do?

It finds every match in the text. Without g, only the first match is returned.

How do capture groups work?

Parentheses capture part of a match. (\d{4})-(\d{2})-(\d{2}) captures year, month and day as $1, $2 and $3.

What is the email pattern in the sample?

[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,} which finds support@fasttoolkit.com and sales@example.org in the sample text.

Can I replace matches with group values?

Yes. Use $1, $2 in the replace box. For dates, $3/$2/$1 turns 2026-11-28 into 28/11/2026.

Why does my pattern match too much?

Greedy quantifiers like .* take as much as possible. Use lazy forms like .*? or negated classes like [^>]* to stop early.

Is my text stored anywhere?

No. Testing runs in your browser. Patterns and text are never sent to a server or stored.


Author

Awais Arshad

Web Tools Developer & Content Creator at FastToolKit.