Split string at every Uppercase character in Javascript
To split a string on capital letters, call the split() method with the following regular expression - /(?=[A-Z])/. The regular expression uses a positive lookahead assertion to split the string on each capital letter and return an array of the substrings.
const str = 'OneTwoThree';
const result = str.split(/(?=[A-Z])/);
// 👇️ ['One', 'Two', 'Three']
console.log(result);
js split string on capital letter second
'ThisIsTheStringToSplit'.split(/(?=[A-Z])/); // positive lookahead to keep the capital letters