🔤

Regex Tester

Test regular expressions with live match highlighting. Free, instant, private.

💻 Developer Tools Free Browser-based
Tool
/ /

What Is a Regular Expression?

A regular expression (regex) is a pattern that describes a set of strings. Instead of searching for one exact word, a regex lets you search for any string that matches a rule — for example, "any 10-digit number" or "any email address". Regex is supported in almost every programming language (JavaScript, Python, PHP, Java, Go) and in text editors like VS Code and Sublime Text. Mastering a few patterns lets you validate form inputs, extract data from logs, find-and-replace across files, and parse structured text with a single line of code.

Regex Flags

FlagMeaningWhen to use
gGlobal — find all matchesAlmost always; without it only the first match is returned
iCase-insensitiveWhen casing doesn't matter: hello matches Hello and HELLO
mMultiline — ^ and $ match line starts/endsWhen testing patterns against multi-line input
sDotAll — . matches newlines tooWhen your target text spans multiple lines

Regex Quick Reference

PatternMatches
.Any character except newline
\dDigit (0–9)
\wWord character (a–z, A–Z, 0–9, _)
\sWhitespace (space, tab, newline)
^Start of string / line
$End of string / line
*0 or more of the previous
+1 or more of the previous
?0 or 1 of the previous (optional)
{n,m}Between n and m repetitions
(abc)Capture group
(?:abc)Non-capturing group
a|ba or b
[abc]Character class (a, b or c)
[^abc]Negated class (anything except a, b or c)

Common Regex Patterns

Use casePattern
Email address[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
URLhttps?://[^\s]+
IPv4 address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
Date YYYY-MM-DD\d{4}-\d{2}-\d{2}
Hex color#[0-9a-fA-F]{3,6}
Whole number^\d+$
Slug (URL-safe)^[a-z0-9]+(?:-[a-z0-9]+)*$
bold" returns the whole string greedily, but <.+?> returns just "".'], ['q' => 'Can I use this regex directly in my code?', 'a' => 'Yes — the patterns are standard JavaScript RegExp syntax. Copy the pattern and wrap it: const rx = /your-pattern/flags; or new RegExp("your-pattern", "flags").'], ]" />