I've got the following
var example = "caty not caby";
[ "c", "y not caby" ]
["c","ty not caby"]
Other answers have mentioned negative lookahead but I'll try to explain why you need to use it.
a[^b] matches a and the next character, as long as it's not b, so it's always going to be two. In your example string, that is "caty not caby" because at matches both of those.
Lookahead patterns, however are called zero width because they do a check but are not considered part of the match, so
a(?!b) will match exactly one character, even though the pattern used both a and b.
caty not caby ^^ ^ || checked and rejected || |checked but not considered part of the match character matched because the lookahead test passed
So, this is why this works.
var example = "caty not caby"; var split = example.split(/a(?!b)/) console.log(split);