.* Regex Tester

Test regular expressions live against your text with match highlighting

Pattern

/ /
✓ Valid pattern 0 matches

Test String

Highlighted Matches

Match Details

Quick Reference

\d
Any digit
\w
Word character
\s
Whitespace
.
Any character
+
One or more
*
Zero or more
?
Zero or one
^
Start of string
$
End of string
[abc]
Any of a, b, c
(...)
Capture group
{2,4}
Between 2-4 times

Getting Started with Regular Expressions

Regular expressions (regex) are patterns used to match, find, or replace text based on rules rather than exact strings. They're essential for form validation, search-and-replace operations, log file parsing, and data extraction across virtually every programming language.

Regex can look intimidating at first because of its dense symbolic syntax, but most real-world patterns combine just a handful of common building blocks — character classes, quantifiers, and anchors — which become familiar quickly with practice.

Essential Regex Building Blocks

Common Flags Explained

Frequently Asked Questions

Why isn't my pattern matching what I expect?
Common culprits include forgetting to escape special characters (like . or $) that you want matched literally, missing the global flag when expecting multiple matches, or case sensitivity issues that the "i" flag would resolve. Testing incrementally — starting simple and adding complexity — usually isolates the issue quickly.
What's the difference between greedy and lazy matching?
By default, quantifiers like + and * are "greedy," matching as much text as possible. Adding a ? after them (like +? or *?) makes them "lazy," matching as little as possible. This matters most when matching content between repeated delimiters, like extracting text between HTML tags.
Is regex the same across all programming languages?
Mostly, but not entirely — the core syntax is similar across JavaScript, Python, PHP, and most languages, but there are subtle differences in supported features (like lookbehind support, named groups syntax, or Unicode handling). This tool uses JavaScript's regex engine specifically.

Related Calculators