Regular expressions (regex) are powerful but notoriously hard to write correctly. This guide explains how to test regex patterns online and covers the most useful syntax.

โšก Try It Free โ€” No Signup

Works instantly in your browser. No account, no install, no upload.

Open Regex Tester โ†’

Regular Expression Basics

A regular expression is a sequence of characters that defines a search pattern. Used for validating input, finding text, extracting data, and replacing strings.

Essential Regex Syntax

PatternMeaningExample
.Any charactera.c โ†’ "abc", "a1c"
*0 or moreab* โ†’ "a", "ab", "abb"
+1 or moreab+ โ†’ "ab", "abb"
?0 or 1colou?r โ†’ "color", "colour"
\dAny digit\d+ โ†’ "123"
\wWord character\w+ โ†’ "hello"
^Start of string^Hello
$End of stringworld$

Common Regex Patterns

# Email validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

# URL
https?://[^\s/$.?#].[^\s]*

# Phone number (US)
\+?1?\s?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}

# IPv4 address
(?:\d{1,3}\.){3}\d{1,3}

# Hex color
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})

Regex Flags

Frequently Asked Questions

What regex flavor does the tester use?
JavaScript (ECMAScript) regex, which is the same engine used in all modern browsers and Node.js.
How do I match a literal dot?
Escape it with a backslash: \. matches a literal dot. Without the backslash, . matches any character.
What are capture groups?
Parentheses () create capture groups that extract specific parts of a match. For example, (\d{4})-(\d{2})-(\d{2}) on a date string captures year, month, and day separately.
Why does my regex work in Python but not JavaScript?
Different languages use slightly different regex flavors. Python supports lookbehind with variable length; JavaScript doesn't (pre-ES2018). Always test in the environment you'll use.

Ready to try it?

Free, instant, and runs entirely in your browser.

Open Regex Tester โ†’