How to split a string based on capital letter in JavaScript

1 Answer

0 votes
const s = "JavaScriptPythonC++";
 
const arr = s.split(/(?=[A-Z])/);
 
console.log(arr);
 
 

 
 
/*
run:
 
["Java", "Script", "Python", "C++"]
 
*/

 



answered May 23, 2021 by avibootz
edited May 1, 2022 by avibootz
...