It's indeed a bit confusing and the comments on the code or the docs do not help that much, but currently what's doing is returning what's
not matched by the regex, but also empty results where the match happened, which means that it offsets the index where the result is. Basically you have to know beforehand where the (opposite of the) match will be.
So if you have
3b
and pass
[a-z]
it will match
b
but return what it did not match,
3
as index
0
, but also an empty string at index
1
.
Now if you use
[0-9]
then it will match
3
and return it as an empty string at index
0
, then what not matched,
b
at index
1