Javascript examples for RegExp:Modifier
Perform a global replacement:
<!DOCTYPE html> <html> <body> <p id="demo">this is a test blue red yellow</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* ww w . j a v a2 s. c o m*/ var str = document.getElementById("demo").innerHTML; var res = str.replace(/blue/g, "red"); document.getElementById("demo").innerHTML = res; } </script> </body> </html>