Regex Group
Capture groups using () and backreferences. Groups part of a pattern to capture and reuse matched substrings.
A regex group encloses part of a pattern in parentheses () to group it. Capture groups remember the matched substring, which can be reused via backreferences or in replacements.
In JavaScript, match() and exec() return capture group values in the result array. Named groups (?<name>...) allow access via groups.name, improving readability. Advanced regex books cover sophisticated group usage.
Non-capturing groups (?:...) group without remembering the match. They are useful in performance-sensitive scenarios.
Backreferences \1, \2 match the same string previously captured by a group. They are used for tasks like validating matching HTML open and close tags. Programming text processing books demonstrate practical backreference examples.