The parentheses are the reason. Here’s what MDN says on string.split
says:
If separator
is a regular expression that contains capturing parentheses, then each time separator is matched the results (including any undefined results) of the capturing parentheses are spliced into the output array.
They also caution:
However, not all browsers support this capability.
So this result may be inconsistent. If you just want to split by the content of the expression, remove the parentheses:
>> 'test.thing.other'.split(/[a-z]+\./)
["", "", "other"]
Which may also not be what you want, but is the intuitively expected result given your expression.
If you want to split by dot then you need to provide exactly that in the regular expression: a dot.
>> 'test.thing.other'.split(/\./)
["test", "thing", "other"]