Javascript examples for RegExp:Match HTML
Use Regular expressions in javascript and replace html tag
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww .jav a 2s .co m var text = 'Some text...<div class=example><pre><ul><li>Item</li></ul></pre><div class=showExample></div></div>Some text...'; console.log(text); match = text.match(/<pre>(.*?)<\/pre>/)[1]; match = match.replace(/</g, '<').replace(/>/g, '>'); text = text.replace(/<pre>.*?<\/pre>/, '<pre>'+match+'</pre>'); console.log(text); } </script> </head> <body> </body> </html>