When using the following regex
([^\s]+)(\s+([^\s]+))*
to match strings like this one
\cmd 1 2
the object returned from the match contains
0: \cmd 1 2
1: \cmd
2: 2
3: 2
I noticed that when a match is contained inside round brackets it will be added a new element in the returning object but why the third element is matching 2
instead of 1
?