Split punctuated strings into regular words greater than 2 character - Javascript RegExp

Javascript examples for RegExp:RegExp test

Description

Split punctuated strings into regular words greater than 2 character

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 av a  2s . c  o m
var str = "this is a test234#$%$%^$%^$%^, is the \"best\" test test test .wer.wer.wer.we.rw.er.w.er!";
str = str.replace(/[^\w\s]/ig, "").replace(/\s/g, ", ");
console.log(str);
    });

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

Related Tutorials