^Useful for line-based matching with multiline mode or full-string validation when combined with `$`.
Core regular expression syntax, classes, quantifiers, groups, lookarounds, flags, and performance techniques.
Match start/end positions and boundaries rather than literal characters.
^Useful for line-based matching with multiline mode or full-string validation when combined with `$`.
$Use with `^` for full-line or full-string matching.
\bCommon for matching whole words like `\berror\b`.
\BUseful for matching substrings that must stay inside a larger token.
\ACommon in PCRE, Ruby, and Python-style engines; safer than `^` when multiline mode is enabled.
\ZOften used with `\A` for strict whole-string matches in PCRE-style engines.
Match one character from a set or shorthand class.
\dEquivalent to `[0-9]` in many engines.
\DInverse of `\d`.
\wUsually letters, digits, and underscore; exact behavior varies with Unicode settings.
\WInverse of `\w`.
\sOften includes spaces, tabs, newlines, and other space-like code points.
\SInverse of `\s`.
[a-z]A range inside square brackets matches one character between the endpoints.
[^0-9]A leading `^` inside `[]` negates the class.
[-_]Put `-` first or last, or escape it, to avoid range behavior.
\p{L}Available in engines with Unicode property support.
\p{N}Useful for international numeric content beyond ASCII digits.
Control how many times the previous token may repeat.
ab*Matches `a`, `ab`, `abb`, and so on.
ab+Requires one or more `b` characters after `a`.
colou?rMatches both `color` and `colour`.
\d{4}A common pattern for year-like numeric fields.
Match between a minimum and maximum number of repetitions.
\w{3,10}Useful for usernames and token length checks.
\d{2,}Useful when only the lower bound matters.
<.*?>Common for tag-like extraction where greedy matching would overrun.
".+?"Useful for quoted strings without crossing too far.
\d++Supported in PCRE/Java-style engines; useful to reduce catastrophic backtracking.
Capture, group, and branch patterns.
(\d{4})-(\d{2})-(\d{2})Groups can be referenced later by number.
(?:cat|dog)Prefer when grouping is needed but capture data is not.
error|warning|infoEquivalent to logical OR across branches.
^(?:https?|ftp)://([^/\s]+)Captures the host while allowing several schemes.
^(?:\+1[-.\s]?)?\d{3}[-.\s]?\d{3}[-.\s]?\d{4}$Common for optional prefixes in validators.
(?|(Mr|Ms)\.?\s+(\w+)|(Dr)\.?\s+(\w+))PCRE feature useful when alternate branches should expose the same capture numbers.
Reuse earlier captures within the same regex.
\b(\w+)\s+\1\bUseful for finding duplicated words like `the the`.
(["\']).*?\1Captures either single or double quote and requires the same closer.
<([A-Za-z][A-Za-z0-9]*)\b[^>]*>.*?</\1>Works for simple tag-like text, though regex is not a full HTML parser.
(?<word>\w+)\s+\k<word>Named syntax varies by engine but improves readability.
Assert context without consuming characters.
\w+(?=:)Matches the word before a colon without including the colon.
foo(?!bar)Matches `foo` not followed by `bar`.
(?<=\$)\d+(?:\.\d{2})?Matches a currency amount after a dollar sign.
(?<!\$)\b\d+\bMatches bare numbers not immediately preceded by `$`.
(?:(?!END).)+Useful when you need to stop before a sentinel substring.
Inline and external flags that modify matching behavior.
(?i)errorEquivalent to using an external ignore-case flag in many tools.
(?m)^ERROR:Useful for log parsing.
(?s)<script.*?</script>Useful when matching across line breaks.
(?x) ^ \d{4} - \d{2} - \d{2} $Improves readability for long patterns.
(?u)\b\p{L}+\bExact syntax varies by engine, but the idea is to use Unicode classes safely.
(?i:api)-v[0-9]+Applies case-insensitive matching just to the group.
Match literal symbols safely.
\.Dot is special outside a character class, so escape it when matching a literal `.`.
\\Backslashes themselves must usually be escaped.
[\^\$\.\|\?\*\+\(\)\{\}]A class can list literal metacharacters more conveniently.
\Q[a-z]+(foo)?\ESupported in PCRE-style engines to avoid escaping many characters one by one.
Patterns that avoid pathological backtracking.
(?>\d{4}-\d{2}-\d{2})Supported in PCRE/Java-style engines; useful in complex validators.
Consume as much as possible without backtracking.
[A-Z]++Can reduce backtracking in ambiguous patterns.
(.*a)*Nested unlimited quantifiers can explode on some inputs. Prefer more precise tokens and anchors.
Use explicit stop characters instead of dot-star where possible.
<title>[^<]*</title>Usually faster and more predictable than `<title>.*?</title>`.