← Guide List GUIDE
A rundown of capture groups, named groups, and lookaround.

Parentheses (...) create a capture group. You can pull the matched part out as a separate piece or reuse it in a replacement with $1·$2. If you want a group but don't want the capture, use (?:...) for a non-capturing group.

(?<name>...) is a named capture group. Being able to access it by name instead of by number improves readability as the pattern grows longer. In replacements you reference it with $<name>.

Lookahead (?=...) matches a position followed by a certain pattern, and (?!...) matches a position not followed by it, without consuming that part. Lookbehind (?<=...) and (?<!...) check what comes before in the same way.

The key point of lookaround is that it is a "condition that isn't consumed." It is powerful when you need to stack several conditions at once, like a strong-password check, or when you want to replace only in a specific context.