Skip to regex tester
/.*/

Regex Tester - Free Online Regex Tester & Debugger

Last updated:

100% Free, Instant Online Regular Expression Tester & Match Finder.

/
/

Match results

Advertisement

Why use Regex Tester

Regex Tester: an online regex tester and match finder

Regex Tester is a free online regex pattern tester, regular expression checker and regex match finder built on the JavaScript RegExp engine. Type a pattern, paste some text, and every match is highlighted as you type. Each match is listed with its position and capture groups, so you can debug a regular expression instead of guessing. Everything runs locally in your browser: your text and patterns are never sent anywhere.

How to test a regular expression

Enter your pattern between the slashes, switch the flags you need, then paste your sample text into the test string. Matches are colour-coded on the left and detailed on the right. If the pattern has a syntax error, the message from the engine appears under the pattern so you can fix it. Pick a preset for emails, phone numbers, URLs, IP addresses or HTML tags to start from a working example.

Regex tester FAQ

What is a regular expression?

A regular expression (regex) is a compact pattern that describes a set of strings. It is used to search, validate, extract and replace text in code editors, command-line tools and programming languages.

How do regex flags like g and i work?

Flags change how a pattern is applied. The g flag (global) finds all matches instead of stopping at the first. The i flag ignores upper and lower case. The m flag makes ^ and $ match at every line, and the s flag lets the dot match line breaks.

How to test regex for email validation?

Choose the Email preset or enter a pattern such as [\w.+-]+@[\w-]+\.[\w.-]+, then paste sample addresses into the test string. Valid addresses are highlighted. Treat regex as a quick format check only; confirm real addresses by sending a message.

Is my text sent to a server?

No. Regex Tester runs entirely in your browser with JavaScript. Your patterns and test strings are never uploaded or stored.

Which regex flavor does Regex Tester use?

It uses the JavaScript (ECMAScript) RegExp engine built into your browser, including lookaheads, lookbehinds in modern browsers, and named capture groups.

Is Regex Tester free and safe to use?

Yes. Regex Tester is free, needs no sign-up, and is safe for sensitive text because all matching runs locally in your browser with no server or backend.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Useful patterns to start from

Paste one of these into the pattern box and adjust it to your data. They are format checks, not full validators.

PatternWhat it matches
^\d{5}(-\d{4})?$US ZIP code, with or without the 4-digit extension
^\d{4}-\d{2}-\d{2}$Date in YYYY-MM-DD form (does not check that the date exists)
^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$Hex color such as #fff or #1a2b3c
\b(\w+)\s+\1\bRepeated words such as "the the" (add the i flag)
^\s+|\s+$Leading and trailing spaces (use with g and m)
https?://\S+Web addresses inside text
-?\d+(\.\d+)?Whole numbers and decimals, including negatives
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$At least 8 characters with a digit, a lowercase and an uppercase letter

For a quick reminder of each token, see the Regex Cheat Sheet.

Greedy and lazy quantifiers

By default, *, + and {n,} are greedy: they match as much text as possible and only give some back if the rest of the pattern fails. Run <.+> against <b>bold</b> and you get one match covering the whole string, not two tags.

Adding a question mark makes the quantifier lazy, so it matches as little as possible. <.+?> finds <b> and </b> separately. Often a negated class is clearer still: <[^>]+> means "anything except a closing bracket" and avoids the issue entirely.

The same rule applies to *?, ?? and {2,5}?. Lazy quantifiers are not faster or safer by default; they simply prefer shorter matches. Use the match list on the right to confirm each match starts and ends where you expect.

Escaping special characters

These characters have special meaning and need a backslash to match literally: . * + ? ^ $ { } ( ) | [ ] \ /. So 3.14 also matches "3x14", while 3\.14 matches only the number. Inside a character class most of them lose their meaning, so [.?] matches a dot or a question mark.

When you move a tested pattern into code as a string, for example new RegExp("\\d+") in JavaScript, every backslash must be doubled. A regex literal such as /\d+/ needs no extra escaping.

When a pattern works here but not in your code

To read an unfamiliar pattern piece by piece, try the Regex Explainer.

More questions about Regex Tester

Why does my regex match much more text than I expected?

A greedy quantifier like .+ or .* is probably running to the last possible position. Make it lazy with .+? or use a negated class such as [^,]+.

How do I match a literal dot or question mark?

Put a backslash in front of it: \. or \?. Inside square brackets, such as [.?], no backslash is needed.

Will a pattern tested here work in Python or PHP?

Most basic patterns work the same, but named groups, lookbehind rules and some advanced features differ between flavors. Test again in the target language for anything beyond simple matching.

How do I make a pattern match a whole word only?

Wrap it in word boundaries: \bcat\b matches cat but not category or concatenate. Word boundaries in JavaScript treat only letters, digits and underscores as word characters.

Why does ^ only match the start of the whole text?

Without the m flag, ^ and $ refer to the start and end of the entire input. Turn on m to make them match at every line.