Test and debug regular expressions in real time with match highlighting, capture groups, substitution, flags control, and a built-in cheat sheet.
g flag for global matching (all occurrences).(?<name>...) for named capture groups.Regular expressions (regex) are sequences of characters that define search patterns. They are one of the most powerful tools in a developer's arsenal, used for text validation, parsing, search-and-replace operations, and data extraction across virtually every programming language.
A regex pattern can match literal characters (abc), character classes ([a-z], \d, \w), quantifiers (*, +, {2,5}), anchors (^, $, \b), and groups (() for capture, (?:) for non-capture). These building blocks combine to create patterns that can match anything from simple email addresses to complex nested structures.
Flags modify how the regex engine processes patterns: g (global) finds all matches instead of stopping at the first, i (case-insensitive) ignores letter case, m (multiline) makes ^ and $ match line boundaries, s (dotAll) makes . match newlines, and u (unicode) enables full Unicode support.
Capture groups enclosed in parentheses () extract specific portions of a match. They're essential for parsing structured data like dates ((\d{4})-(\d{2})-(\d{2})), URLs, log files, and configuration values. Named groups (?<name>...) make patterns more readable and maintainable.
Common pitfalls include catastrophic backtracking (nested quantifiers like (a+)+), forgetting to escape special characters (., *, ?), and writing overly complex patterns. When possible, break complex patterns into smaller, tested components.