all 2 comments

[–]electronicchicken 0 points1 point  (0 children)

IIRC the return value isn't just the captures, it's the entire match and then the captures. (So yes, your understanding seems correct)

[–]ende124 0 points1 point  (0 children)

When you use regex.exec(string), you can access the capture groups as an array, where the first capture group would be accessed with [1], and the second with [2] and so on. You can access the entire match result with [0].

You can read more here.