>_
smartdevbox
Try SmartDevBox free — no sign-up91+ tools · 100% client-side · no account required
Glossary

What Is a Regex (Regular Expression)?

A regular expression (regex) is a compact pattern that describes a set of strings. Regex engines scan text to find — and optionally replace — any substring that matches the pattern. They are built into every major programming language and are indispensable for input validation, log parsing, search-and-replace, and data extraction.

The One-Line Definition

A regular expression is a sequence of characters that defines a search pattern. A regex engine tests whether a string (or part of it) matches that pattern.

Core Syntax Reference

TokenMeaning
.Any character (except newline by default)
\dAny digit — equivalent to [0-9]
\wWord character — [a-zA-Z0-9_]
\sWhitespace — space, tab, newline, etc.
[abc]Character class — matches a, b, or c
[^abc]Negated class — matches anything except a, b, c
^Anchor — start of string (or line with m flag)
$Anchor — end of string (or line with m flag)
*Quantifier — 0 or more (greedy)
+Quantifier — 1 or more (greedy)
?Quantifier — 0 or 1; also makes * or + lazy when appended
{n,m}Quantifier — between n and m occurrences
(abc)Capturing group — matches abc and captures the result
(?:abc)Non-capturing group — groups without capturing
a|bAlternation — matches a or b

Practical Examples

ISO date (YYYY-MM-DD)Pattern: ^\d{4}-\d{2}-\d{2}$
Matches: 2024-01-15
Email address (simplified)Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Matches: ada@example.com
URL starting with http or httpsPattern: https?://[^\s]+
Matches: https://example.com/path?q=1
UUID v4Pattern: ^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$
Matches: 550e8400-e29b-41d4-a716-446655440000

Greedy vs Lazy Quantifiers

Greedy (.*)Matches as much as possible. Given <a>foo</a><b>bar</b>, the pattern <.*> matches the whole string.
Lazy (.*?)Matches as little as possible. The pattern <.*?> matches only <a> — stopping at the first >.

Test a Regex Now

Test any regex pattern against your input in real time. Open the Regex Tester →

Frequently Asked Questions

What is the difference between greedy and lazy quantifiers?

* and + are greedy — they match as much as possible. *? and +? are lazy — they match as little as possible. Greedy is the default; lazy is safer when parsing HTML or nested structures.

What are regex flags?

Flags modify matching behavior. Common ones: i (case-insensitive), g (global — find all matches), m (multiline — ^ and $ match line start/end), s (dotAll — . matches newlines too).

How do I test a regex online?

Use the Regex Tester on SmartDevBox. Paste your test string and pattern; matches are highlighted in real time with full flag support.

Regex Tester ToolReal-time regex matching with match highlighting and flag support.
What Is a UUID?UUIDs are often validated with a regex pattern.