Use regex to match multiple word with spaces/multiple space or no spaces - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Use regex to match multiple word with spaces/multiple space or no spaces

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() {/*  w w  w.  j a va 2 s  . c o m*/
var string="Hi I am bob \
hi \
Hi         I  am        Bob";
var regex=/\b\w+\b/g;
var results=string.match(regex);
document.write(results.join("<br/>"));
    });

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

Related Tutorials