Regex Pattern & Test String

Test ResultsLive

Enter a regex pattern and test string to see live results...

Free Regex Tester — Online Regular Expression Validator & Debugger

Test, debug, and validate regular expressions online with live match highlighting, capture group details, and real-time error feedback. Supports all JavaScript regex flags — no sign-up required.

What Is a Regex Tester?

A regex tester (regular expression tester) is an online tool that lets you write, test, and debug regex patterns against sample text in real time. Regular expressions — shortened to regex or regexp — are sequences of characters that define a search pattern. They are used by virtually every programming language and developer tool for string matching, validation, extraction, and find-and-replace operations.

Writing a correct regular expression without a tester is notoriously error-prone. A single misplaced quantifier, forgotten escape character, or wrong flag can cause a pattern to match nothing, match too much, or behave differently across languages. Our online regex tester provides instant visual feedback — highlighting every match in the test string, showing exact character positions, and displaying all capture groups and named groups — so you can iterate and fix patterns interactively rather than guessing.

This tool runs entirely in your browser using the JavaScript regex engine (ECMAScript standard), which means your test strings and patterns are never sent to any server.

How to Use the Regex Tester — Step by Step

  1. Enter your regex pattern in the "Regular Expression" field. Do not include forward-slash delimiters (/pattern/) — enter the pattern only.
  2. Configure flags using the toggle switches. Enable g (Global) to find all matches, not just the first. Enable i (Ignore Case) for case-insensitive matching, m (Multiline) for multi-line anchors, and so on.
  3. Enter your test string — paste any text you want to match against: an email list, a log file snippet, a URL, JSON data, or any other content.
  4. Enable Live Test (on by default) to see results update as you type. The results panel highlights every match instantly.
  5. Review match details — each match shows its exact position in the string, the full matched text, and any capture groups (numbered and named).
  6. Copy results with the Copy button, or switch to Fullscreen mode for a better view when working with large inputs.
  7. Use the Sample button to load a pre-built email validation regex and test string to explore the tool's features.

Regex Flags — Complete Reference

Regex flags modify how the pattern engine processes your expression. This tool supports all six standard JavaScript flags:

g — Global

Find all matches in the string, not just the first one. Without this flag, the engine stops at the first match. Essential for extracting all occurrences of a pattern from a block of text.

i — Ignore Case

Makes matching case-insensitive. The pattern [a-z] will also match A-Z. Use for email validation, keyword matching, and any search where case differences are irrelevant.

m — Multiline

Changes the behavior of ^ and $ anchors. Without this flag, ^ and $ match the start and end of the entire string. With m, they match the start and end of each individual line.

s — Dot All

Makes the . metacharacter match every character including newline characters (\n). Without this flag, . does not match newlines, which can cause surprises with multi-line strings.

u — Unicode

Enables full Unicode support. Required for correctly matching Unicode code points above U+FFFF (like emoji), Unicode property escapes (\p{Letter}), and proper surrogate pair handling.

y — Sticky

Only matches starting at the exact position of lastIndex — it does not search ahead in the string. Useful for incremental tokenization and parsing, where you process a string position-by-position.

Regex Metacharacters & Syntax Cheat Sheet

PatternMeaningExample
.Match any character except newline. → matches a, 1, @
\dMatch any digit (0–9)\d+ → matches 123
\wMatch word character (a-z, A-Z, 0-9, _)\w+ → matches hello_1
\sMatch whitespace (space, tab, newline)\s+ → matches spaces
^Start of string (or line with m flag)^Hello → only at start
$End of string (or line with m flag)world$ → only at end
*Zero or more of precedingab* → a, ab, abb
+One or more of precedingab+ → ab, abb (not a)
?Zero or one of preceding (optional)colou?r → color, colour
{n,m}Between n and m repetitions\d{2,4} → 12, 123, 1234
[abc]Match any character in set[aeiou] → vowels
[^abc]Match any character NOT in set[^0-9] → non-digits
(abc)Capture group(\d+) → captures digits
(?<name>)Named capture group(?<year>\d{4})
(?:abc)Non-capturing group(?:https?) → no capture
a|bMatch a or bcat|dog → cat or dog
\bWord boundary\bword\b → exact word
(?=abc)Positive lookahead\d(?= px) → digit before px
(?!abc)Negative lookahead\d(?! px) → digit NOT before px

Common Regex Patterns — Ready to Use

Copy any of these production-ready patterns into the tester above:

Email Address\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b
URL (http/https)https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)
IPv4 Address\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b
Phone Number (US)\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
Date (YYYY-MM-DD)\b\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])\b
Hex Color Code#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b
HTML Tag<\/?[a-z][a-z0-9]*(?:\s[^>]*)?>
Password (min 8 chars, 1 upper, 1 digit)^(?=.*[A-Z])(?=.*\d)[A-Za-z\d@$!%*?&]{8,}$
Slug / URL Path^[a-z0-9]+(?:-[a-z0-9]+)*$
Indian Mobile Number^[6-9]\d{9}$

Regex Use Cases — Who Uses Regular Expressions?

Web Developers

Validate form inputs (email, phone, password, ZIP code), parse URL parameters, sanitize user-submitted text, and write routing rules in web frameworks like Express, Django, and Rails.

Data Engineers & Analysts

Extract structured fields from raw log files, clean messy CSV data, parse server access logs, find patterns in large datasets, and write ETL transformation rules in Python (re module), SQL, or Spark.

SEO Professionals

Use regex in Google Search Console and Google Analytics to filter branded vs. non-branded queries, segment URL patterns, isolate informational vs. transactional keywords, and automate redirect mapping.

DevOps & System Administrators

Parse application logs for error patterns, write Nginx/Apache rewrite rules, filter systemd journal output with grep, configure monitoring alert rules, and extract metrics from log streams.

QA & Test Engineers

Write test assertions that match dynamic output, validate API response formats, create test fixtures with pattern-based data generation, and build automated input validation test cases.

Content Writers & Editors

Use find-and-replace in VS Code, Sublime Text, or Notepad++ with regex to bulk-reformat content, fix inconsistent punctuation, or extract specific data from exported CMS content.

Frequently Asked Questions — Regex Tester

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. It is a formal language for pattern matching within strings. Regex patterns can describe simple things (a specific word) or complex structures (all valid email addresses, all IPv4 addresses). They are supported in JavaScript, Python, Java, PHP, Go, Rust, C#, Ruby, and essentially every modern programming language.

What regex flavor does this tool use?

This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. It supports all standard metacharacters, lookaheads, lookbehinds (ES2018+), named capture groups, Unicode property escapes (with the u flag), and all six flags (g, i, m, s, u, y). Note that JavaScript regex differs slightly from PCRE (PHP, Python) and .NET regex — particularly in some advanced features.

What are capture groups and how do I use them?

Capture groups are portions of a regex enclosed in parentheses (). They capture the text matched by that part of the pattern for later use. For example, in (\d{4})-(\d{2})-(\d{2}), group 1 captures the year, group 2 the month, group 3 the day. Named capture groups use the syntax (?<name>pattern) and are accessible by name. The tool displays all captured groups for every match.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. For example, in the HTML <b>bold</b><i>italic</i>, the pattern <.+> greedily matches the entire string, while <.+?> lazily matches each individual tag. Use lazy quantifiers when you need to match the shortest possible string.

Why does my regex match more than expected?

This usually happens because: (1) you're missing anchors — add ^ at the start and $ at the end for exact matching; (2) you're using a greedy quantifier when a lazy one is needed; (3) your character class is too broad; or (4) the g (global) flag is finding additional partial matches you didn't anticipate. The live highlighting in this tool makes it easy to spot unintended matches.

How do I test a regex for email validation?

Click the Sample button to load a pre-built email regex with test strings. The standard email validation pattern is \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b. Enable the g flag to find all emails in a block of text and the i flag for case-insensitive matching. Note that a 100% accurate email regex is extremely complex; for production use, combine a simple regex with server-side confirmation email.

Can I use this regex tester for Python or PHP patterns?

This tool uses the JavaScript (ECMAScript) regex engine. Most standard patterns work identically across JavaScript, Python, PHP, Java, and Go. However, there are differences: Python uses (?P<name>) for named groups (JavaScript uses (?<name>)), .NET supports possessive quantifiers and atomic groups (JavaScript doesn't), and PCRE supports some extended features not in JavaScript. For JavaScript-specific applications, this tool is fully accurate.