Javascript examples for String Operation:String Replace
Use Regex to Replace substring
<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>