Javascript examples for String:replace
Replace part of a string based on a group of letters in the matched string
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w ww . j a va 2 s. c om regex=/(.*class=\'ss-)(.*?)(\'>)(.*?)(<\/.*)/; str="<i class='ss-icon'>this is a test</i><i class='ss-icon'>this is a test</i>"; var newStr=str.replace(regex, "$1$4$3$5"); console.log(newStr) } </script> </head> <body> </body> </html>