Regex Grouping
Parentheses Grouping ()
Parentheses are used to group characters together.
For example, the regex pattern (go)+gle
matches gogle
and gogogle
.
Referencing a Group
You can reference a group using a backslash followed by the group number.
For example, the regex pattern ([0-9])\1
matches any repeated digit.
Parentheses Non-Capturing Group (?:)
A non-capturing group is used to group characters without capturing the match. So you can’t reference it later.
For example, the regex pattern (?::go)+gle
matches gogle
and gogogle
.