Split string into sentences inside <p> element via regex - Javascript String Operation

Javascript examples for String Operation:String Split

Description

Split string into sentences inside <p> element via 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  v a  2 s  .  com
value = '<p>line1</p><p>line2</p><p>line3</p>';
var v = value.replace(new RegExp("<p>(.*?)<\/p>", "g"), '$1\n');
var lines = v.split("\n");
console.log(lines);
    }

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

Related Tutorials