Javascript examples for String Operation:String Replace
Use Regex to Remove Specific Consecutive Duplicate Characters
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w w w . ja va 2s . co m*/ var oldString = "Aaabbcccccccd*def%testgGGhhhijkklmnoP\\122"; var filtered = oldString.replace(/[^\w\s]|(.)(?=\1)/gi, ""); document.write(filtered); }); </script> </head> <body> </body> </html>