How to split a string by uppercase and lowercase in JavaScript?
([A-Z]+|[a-z]+)
. Match all upper case, or all lower case multiple times in capturing groups. Give this a try here: https://regex101.com/r/bC8gO3/1
Another way to do this is to add in a marker and then split using that marker, in this case a double-exclamation point:
JsBin Example
var s = "HOWtoDOthis";
var t = s.replace(/((?:[A-Z]+)|([^A-Z]+))/g, '!!$&').split('!!');