Regular Expressions (Regex) Syntax & Patterns
Character classes, quantifiers, lookahead, lookbehind, non-capturing groups, word boundaries, and regex flags.
Regular Expressions (Regex) Syntax & Patterns Interactive Command Directory
Browse, search, and copy battle-tested commands & syntax recipes (18 Total Commands).
Standard shorthand character classes for matching types of characters.
Assert position at string edges or word boundaries without consuming characters.
Specify repetition counts. Adding ? makes quantifier match shortest possible string.
Positive lookahead (?=...) asserting string contains uppercase letter and digit.
Positive lookbehind (?<=...) matching currency figures preceded by a dollar sign.
Production RFC-compliant email address validation pattern.
Group tokens without storing matched substring in capture group array.
Compilation flags controlling regex evaluation behavior across lines and cases.
Positive lookahead validating strong passwords: at least 1 uppercase letter, 1 number, 1 special character, and 8+ characters.
Positive lookbehind matching dollar amounts ($12.50) without capturing the leading currency dollar sign.
Negative lookahead matching words that do NOT start with reserved usernames 'admin' or 'root'.
Non-capturing group (?:...) grouping protocol alternatives without storing memory capture buffers.
Assign semantic variable names to captured subgroups for direct access in code (e.g., match.groups.year in JS).
Official SemVer 2.0.0 specification regex validating major.minor.patch versions with pre-release tags.
Strict IPv4 validation matching 0.0.0.0 through 255.255.255.255 without allowing invalid octets like 256.
RFC 4122 version-4 compliant UUID regex verifying 128-bit hexadecimal format with 4xxx and [89ab] variant bits.
Validates RFC 3339 / ISO 8601 UTC timestamps (e.g., 2026-10-29T18:00:00.000Z).
Extract all valid email addresses from application logs using extended POSIX regex.
Companion Developer Tools & Playgrounds
Accelerate command execution and syntax debugging with HelloAIHub suite of interactive tools.
In-Browser Code Runner
Test and benchmark syntax scripts in Node.js, Python, TypeScript, and Go with zero local setup.
Regex Live Tester & Explainer
Debug regular expressions, lookarounds, capture groups, and substitution patterns with live AST explanations.
Dockerfile Generator
Generate multi-stage, rootless, production-hardened Dockerfiles with caching and alpine bases.
System Design Sizing Calculator
Compute real-time QPS, storage bandwidth, cache memory ratios, and replica math for distributed architectures.
Regular Expressions (Regex) Syntax & Patterns: Command Groups & Quick Index
18 indexed entries across 15 sectionsHighlighted Flags & Syntax Examples in Regular Expressions (Regex) Syntax & Patterns
Standard shorthand character classes for matching types of characters.
Assert position at string edges or word boundaries without consuming characters.
Specify repetition counts. Adding ? makes quantifier match shortest possible string.
Positive lookahead (?=...) asserting string contains uppercase letter and digit.
Frequently Asked Questions
Expert recommendations, common traps, and production best practices for Regular Expressions (Regex) Syntax & Patterns.
What is Catastrophic Backtracking in Regular Expressions?
Catastrophic backtracking occurs when nested quantifiers (e.g. (a+)+$) fail to match a string. The regex engine explores an exponential number of permutations, spiking CPU usage to 100% and causing a Denial of Service (ReDoS). Prevent it by avoiding ambiguous overlapping quantifiers.
What is the difference between greedy and lazy matching?
A greedy quantifier (e.g. .*) matches as many characters as possible before backtracking. A lazy quantifier (e.g. .*?) matches as few characters as possible, stopping at the very first match.
What is Catastrophic Backtracking (ReDoS) and how do I prevent it?
Catastrophic backtracking occurs when nested quantifiers (such as (a+)+$) force Non-deterministic Finite Automaton (NFA) engines to explore an exponential number of combinatorial paths when evaluating non-matching input strings. An input of 30 characters can freeze a server for minutes. Prevent ReDoS by avoiding nested quantifiers, using atomic groups (?>...), or adopting linear-time engines like Google RE2.
What is the difference between greedy and lazy (reluctant) matching?
Greedy quantifiers (.*) match as much text as possible and then backtrack. Lazy quantifiers (.*?) match as few characters as possible, expanding only when necessary. For parsing HTML tags, <.*?> matches a single tag, whereas <.*> matches from the first opening tag to the last closing tag on the entire line.
What does the 's' (dotAll) flag do in modern regex?
By default, the dot wildcard (.) matches any character EXCEPT newline characters (\n, \r). Enabling the 's' flag (dotAll mode in JS/PCRE) allows the dot to match newline characters as well, enabling seamless multiline text matching.
What is the difference between word boundary \b and non-word boundary \B?
\b matches the zero-width position between a word character (\w) and a non-word character (\W or line start/end). In contrast, \B matches any position where \b does NOT match (e.g. inside a word).
Cross-Hub Skill Acceleration
Combine command lookups with active coding interviews and complete career paths.
Need More Cheat Sheets?
Explore developer cheat sheets and syntax guides on HelloAIHub.