how do regex groups work?
Regular Expression Reference: Capturing Groups and Backreferences. Parentheses group the regex between them. They capture the text matched by the regex inside them into a numbered group that can be reused with a numbered backreference. They allow you to apply regex operators to the entire grouped regex.