Quick Answer

To use a regex tester, paste your regular expression into the pattern field and your sample text into the test field. The tool highlights every match live as you type, so you can adjust the pattern until only the text you want lights up. Add flags like g for global and i for case insensitive to change how it matches. This lets you build and fix patterns in seconds without running any code.

Regular expressions look intimidating. A string like ^\d{3}-\d{4}$ reads like line noise until someone explains it, and then it clicks. The fastest way to learn is not to memorise syntax but to watch a pattern match text in real time. That is exactly what a regex tester does. This guide explains what regex is in plain English, walks through the syntax you will actually use, hands you ten ready made patterns, and shows you how to test them without writing a single line of code.

Free Tool

Follow along with our free Regex Tester. Paste a pattern, paste some text, and watch matches highlight live. It runs entirely in your browser, so your data never leaves your device.

Open the Regex Tester →

What Is Regex?

Regex, short for regular expression, is a small language for describing patterns in text. Instead of searching for one exact word, you describe the shape of what you want. For example, "three digits, then a dash, then four digits" describes a phone number without you having to list every possible number.

And it isn't new. The idea came from mathematician Stephen Kleene, who formalised it in a 1951 paper for the RAND Corporation, according to Wikipedia. Ken Thompson then built the notation into Unix text editors in 1968, and the classic search tool grep took its name from the editor command g/re/p, short for "global, regular expression, print", per Wikipedia's grep entry. Today regex is supported in almost every programming language, code editor, and many spreadsheet and database tools, which is why the skill pays off everywhere you work with text.

Once you can describe a pattern, you can do powerful things with it: validate that an email or postcode is formatted correctly, find and replace text across a huge file, pull all the links out of a document, or filter a list down to the rows that match. Almost every programming language, code editor, and many spreadsheet and database tools support regex, so the skill transfers everywhere you work with text. Regular expressions in JavaScript are documented by MDN Web Docs. If you want a gentler on ramp to the concepts first, our regex guide for beginners covers the building blocks step by step.

What Is the Basic Regex Syntax?

Regex is built from a handful of pieces. Learn these and you can read most patterns you meet.

PieceMeansExample
.Any single charactera.c matches abc, a2c
\dAny digit 0 to 9\d\d matches 42
\wA word character (letter, digit, underscore)\w+ matches hello_1
\sAny whitespace (space, tab, newline)a\sb matches "a b"
[abc]Any one of a, b, or c[aeiou] matches one vowel
*Zero or more of the previous itemab* matches a, ab, abb
+One or more of the previous itemab+ matches ab, abb
?Zero or one (makes it optional)colou?r matches color, colour
{n}Exactly n of the previous item\d{4} matches 2026
^ $Start and end of the text or line^Hi$ matches only "Hi"
|Or, matches either sidecat|dog matches cat or dog

One rule saves you constant confusion: characters with a special meaning, like . + * ? ( ), must be escaped with a backslash when you want the literal character. To match a real full stop, write \. rather than ., otherwise the dot matches any character at all.

What Are the 10 Most Useful Regex Patterns?

These are the workhorses. Paste any of them into the tester with some sample text to see them in action. They are written to work in JavaScript style regex, which is what most online testers use. The JavaScript regular expression syntax is defined in the ECMAScript specification from Ecma International.

GoalPattern
Email address^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL (http or https)https?:\/\/[^\s]+
International phone (E.164)^\+?[1-9]\d{1,14}$
US phone number^\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$
Date (YYYY-MM-DD)^\d{4}-\d{2}-\d{2}$
Time (24 hour HH:MM)^([01]\d|2[0-3]):[0-5]\d$
Hex colour code^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
IPv4 address^(\d{1,3}\.){3}\d{1,3}$
Whole number or decimal^-?\d+(\.\d+)?$
Only letters and spaces^[A-Za-z\s]+$

A word of caution on the email and IP patterns. The email pattern handles the vast majority of real addresses, but no regex validates every technically valid email, so treat it as a quick client side check and confirm important addresses with a verification email. The simple IPv4 pattern checks the shape but not that each block is 255 or below, which is fine for a first pass filter.

How Do You Use the Free Tester?

Using a regex tester takes four steps, and the live feedback is what makes it such a fast way to learn.

  1. Enter your pattern. Type or paste a regular expression into the pattern field. Start simple, for example \d+ to find numbers.
  2. Paste your test text. Drop in a realistic sample: a few email addresses, a log line, or a paragraph. The tester highlights every match instantly.
  3. Set your flags. Turn on g (global) to find every match rather than just the first, i (case insensitive) to ignore letter case, and m (multiline) so ^ and $ match at each line break.
  4. Refine until it fits. Add and remove pieces of the pattern and watch the highlights change. When only the text you want is lit up, your pattern is ready to copy into your code, editor, or spreadsheet.

Building a pattern piece by piece is the whole trick. Rather than writing a long expression and hoping, add one part at a time and confirm each step matches what you expect before moving on.

Try It Now

Paste one of the patterns above into the free Regex Tester and watch it match. No signup, nothing sent to a server, just instant highlighting in your browser.

Open the Regex Tester →

What Are the Common Mistakes to Avoid?

Most regex frustration comes down to a short list of repeat offenders. Watch for these and you will solve the majority of problems yourself.

  • Forgetting to escape special characters. An unescaped . matches any character, not a literal dot. Writing 3.14 as a pattern also matches "3x14". Use 3\.14 when you mean the dot.
  • Greedy quantifiers grabbing too much. By default .* matches as much as possible. In <.*> against "<a><b>" it grabs the whole thing. Add a ? to make it lazy: <.*?> matches each tag separately.
  • Leaving off the global flag. Without g, the engine stops at the first match. If only one result shows when you expected many, check the flag.
  • Anchors in the wrong place. ^ and $ pin the pattern to the start and end. Using them by accident can make a valid pattern match nothing because the surrounding text does not line up.
  • Confusing [] with (). Square brackets match any one character from a set, while parentheses group a sequence and capture it. [cat] matches a single c, a, or t, not the word cat.
  • Trusting regex for full validation. Regex checks shape, not truth. It cannot confirm an email exists or a date is real. Use it for formatting checks and back it with proper validation where it matters.

Ready to keep learning? Pair this with our beginner regex guide for more worked examples, then keep the Regex Tester open in a tab whenever you write a pattern.

What Else Do People Ask?

What is a regex tester?

A regex tester is a tool where you paste a regular expression and some sample text, then see every match highlighted live as you type. It removes the guesswork from writing patterns by showing you exactly what matches and what does not, so you can fix a pattern in seconds instead of running your code over and over. Our free Regex Tester runs entirely in your browser and never sends your text anywhere.

How do I test a regex pattern without coding?

Open an online regex tester, type or paste your pattern into the pattern field, then paste your sample text into the test field. Matches light up instantly. You do not need to write any code or install anything. Add flags like g for global and i for case insensitive to change how the pattern behaves, and adjust the pattern until only the text you want is highlighted.

What is the regex pattern for an email address?

A practical email pattern is ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$, which covers the vast majority of real addresses. No regex validates every valid email perfectly, so use it for quick client side checks and confirm the address with a verification email for anything important.

What do the g and i flags mean in regex?

Flags change how a pattern runs. The g flag means global, so the engine finds every match in the text rather than stopping at the first. The i flag means case insensitive, so uppercase and lowercase letters are treated the same. The m flag means multiline, which makes the start and end anchors match at each line break rather than only at the start and end of the whole text.

Why is my regex not matching anything?

The most common causes are forgetting to escape special characters like the dot or parentheses, using a greedy quantifier that grabs too much, or leaving off the global flag so only the first match shows. Test small pieces of your pattern one at a time in a regex tester and build up gradually. Watching the highlights change as you add each part makes the problem obvious.

The regex patterns in this guide are written for JavaScript style regular expression engines, which is what most online testers and browsers use. Other languages may differ slightly in escaping and flag syntax. Always test a pattern against realistic sample data before relying on it in production.