Javascript examples for String Operation:String Split
Split string into sentences inside <p> element via regex
<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>