Remove Duplicate Characters


/ Published in: JavaScript
Save to your folder(s)

This function removes repeated characters after second one


Copy this code and paste it in your HTML
  1. function removeDubCharacters (str) {
  2. var reg = /(.)\1{2,}/g;
  3. if(str.match(reg)) {
  4. str = str.replace(reg, '$1$1');
  5. }
  6. return str;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.