Developer

Regex Tester

Test and debug regular expressions with real-time matching, highlighting, and match details. Includes common presets.

Regex Tester

Share:

Regular Expression Testing Guide

Our regex tester provides real-time pattern matching, highlighted match results, match group details, and preset patterns for common validation use cases. Regular expressions (regex) are patterns used to match character combinations in strings — an essential skill for developers, data analysts, and system administrators.

Regex Basics

Literals: Match exact characters. "hello" matches the string "hello". Character classes: [abc] matches a, b, or c. [a-z] matches any lowercase letter. d matches any digit. w matches word characters (letters, digits, underscore). s matches whitespace. Quantifiers: * (0 or more), + (1 or more), ? (0 or 1), {n} (exactly n), {n,m} (between n and m). Anchors: ^ matches start of string/line, $ matches end. Groups: (abc) captures a group. (?:abc) is a non-capturing group. Alternation: a|b matches a or b.

Common Regex Patterns

Email validation: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$. URL: https?://(www.)?[a-zA-Z0-9.-]+.[a-zA-Z]{2,}(/S*)?. Phone (US): ^+?1?s?(?d{3})?[s.-]?d{3}[s.-]?d{4}$. IPv4: ^(d{1,3}.){3}d{1,3}$. Hex color: ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$.

Regex Flags

g (global): Find all matches, not just the first. i (case-insensitive): Treat uppercase and lowercase as equivalent. m (multiline): ^ and $ match start/end of each line, not just the whole string. s (dotAll): . matches newline characters too. u (unicode): Enable full Unicode matching.

Using Our Free Regex Tester

Enter your regex pattern and the test string. Matches are highlighted in real time. Match details show the matched text, position, and captured groups. Use the preset patterns for quick access to common validation patterns. All processing is done locally in your browser.

Frequently Asked Questions

What regex flags are supported?

All JavaScript regex flags: g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line boundaries), s (dotAll — . matches newlines), u (unicode).

How do I match an email address with regex?

A common email pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ — our tester includes this as a preset. Note: fully compliant email validation requires the full RFC 5322 spec, which is extremely complex.

What is the difference between .* and .+?

.* matches zero or more of any character (can match empty string). .+ matches one or more (requires at least one character). Both are greedy by default — add ? after them (.* ? or .+?) to make them lazy (match as few characters as possible).

Why does my regex match too much?

You likely have a greedy quantifier. .* will match as much as possible. Use non-greedy versions (.*?) to match the minimum. Also check anchors — without ^ and $ your pattern can match anywhere in the string.