Javascript examples for RegExp:Match HTML
Use regex to strip out both HTML tags and their contents from a string
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from www . j av a 2 s. c o m*/ var subject = "foo <div>>bar</div>> baz"; var result = subject.replace(/^(.*?)(?:<.*>)(.*?)$/ig, "$1>$2"); console.log(result); } </script> </head> <body> </body> </html>