</>
DevToolHub

Regex Tester

Test and debug regular expressions in real-time. See matches highlighted, capture groups extracted, and errors explained instantly.

Pattern
//g
Test String

Regex Syntax Quick Reference

PatternDescriptionExample
.Any character except newlinea.c matches "abc", "a1c"
*Zero or more of the precedingab*c matches "ac", "abc", "abbc"
+One or more of the precedingab+c matches "abc", "abbc" (not "ac")
?Zero or one of the precedingcolou?r matches "color", "colour"
^Start of string (or line with m flag)^Hello matches "Hello world"
$End of string (or line with m flag)world$ matches "Hello world"
[abc]Character class (any of a, b, or c)[aeiou] matches any vowel
(abc)Capturing group(\w+)@(\w+) captures user and domain
{n,m}Between n and m repetitionsa{2,4} matches "aa", "aaa", "aaaa"
|Alternation (or)cat|dog matches "cat" or "dog"
\dAny digit (0-9)\d{3} matches "123"
\wWord character (letter, digit, underscore)\w+ matches "hello_123"
\sWhitespace (space, tab, newline)\s+ matches spaces between words
\bWord boundary\bword\b matches whole word only

Common Regex Patterns

Use CasePatternNotes
Email address[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Basic validation, not RFC 5322 compliant
URLhttps?:\/\/[^\s/$.?#].[^\s]*Matches http and https URLs
Phone number (US)\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}Matches (123) 456-7890, 123-456-7890, etc.
IP address (IPv4)\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bDoes not validate octets are 0-255
Date (YYYY-MM-DD)\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])ISO 8601 date format

Flags Explained

FlagNameEffect
gGlobalFind all matches, not just the first one
iCase-insensitiveMatch uppercase and lowercase letters interchangeably
mMultiline^ and $ match start/end of each line, not just the whole string
sDotAll. matches newline characters as well
uUnicodeEnables full Unicode support and strict syntax

FAQ

Is my data safe?

Yes. The regex testing happens entirely in your browser using JavaScript's built-in RegExp engine. No text or patterns are sent to any server.

Which regex flavor does this use?

This tool uses JavaScript's native regular expression engine (ECMAScript). Syntax may differ slightly from PCRE (PHP, Python) or POSIX regex in features like lookbehinds and named groups.

Why do I get "invalid regular expression" errors?

Common causes include unescaped special characters (like parentheses or brackets that aren't closed), invalid quantifiers, or using syntax not supported in JavaScript regex. Check that all opening brackets and parentheses have matching closing ones.

What are capture groups?

Parentheses () in a regex create capture groups. They let you extract specific parts of a match. For example, (\d+)-(\d+)on "2024-01" captures "2024" as group 1 and "01" as group 2.

How do I match a literal special character?

Escape it with a backslash. To match a literal dot, use \.. To match a literal backslash, use \\. Characters that need escaping: . * + ? ^ $ { } [ ] ( ) | \