Split a string on the first number occurrence using regex - Javascript RegExp

Javascript examples for RegExp:Match Number

Description

Split a string on the first number occurrence using regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from   w  w  w.j  a  va  2s .com
var str="72 g abc def 101 ddd 108 g aaa 111 spuc loi 32 test";
var regex=/\b(?=\d)/g;
console.log(str.split(regex));
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials