Split a string by uppercase and lowercase using regex - Javascript String Operation

Javascript examples for String Operation:String Split

Description

Split a string by uppercase and lowercase using regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width"> 
   </head> 
   <body> 
      <script>
var s = "HOWtoDOthisAtest";
var t = s.replace(/((?:[A-Z]+)|([^A-Z]+))/g, '!!$&').split('!!');
console.log(t);

      </script>  
   </body>//w  ww.  j  ava 2 s . c om
</html>

Related Tutorials