Use the (?:...) construct to group a regular-expression subexpression for matching without adding its text to the numbered captures. Unlike a zero-width assertion, the group consumes characters; it simply does not save them. section 11.5.3
Grouping without an extra capture
For str = "abc def ghi", /(abc) (?:def) (ghi)/.match(str) produces MatchData "abc def ghi" 1:"abc" 2:"ghi". The matched "def" participates in the full match but does not become capture 2.


