Use Regex only on non-html code - Javascript RegExp

Javascript examples for RegExp:Match HTML

Description

Use Regex only on non-html code

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 2s.  co m
var str = '<strong class="foo">Lorem ipsum strong dolorem</strong>';
var re = /strong(?!(>|\s\w+=))/g;
console.log(str.replace(re, 'REPLACED'))
    });

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

Related Tutorials