Javascript examples for String:split
Splitting a string and preserving the spaces
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . jav a2 s . co m var str = "please help me "; var split = str.split(/(\S+\s+)/).filter(function(n) {return n}); console.log(split) } </script> </head> <body> </body> </html>