Use Regex to Replace substring - Javascript String Operation

Javascript examples for String Operation:String Replace

Description

Use Regex to Replace substring

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(){//  www . j  a  v a  2  s.  co  m
var userinput = '<div id="c16430" style="color:red;" class="css-btn">';
var pattern = /[a-zA-Z0-9.;:|_-]+="[a-zA-Z0-9.;:_-]+\"/g;
userinput = userinput.replace( pattern, "Replaced..." );
console.log(userinput);
    }

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

Related Tutorials