Reputation: 174
I'm using this
html = html.replace(/([^0-9]).*?\1/ , "");
but it's not quite doing what I'm trying to do. I want to replace the doubles within a string, but still keep at least one of them. Can't seem to figure out how to go about this.
Upvotes: 0
Views: 127
Reputation: 174706
THink you mean this,
str.replace(/(.)\1+/g, '$1')
or
str.replace(/([^0-9])\1+/g, '$1')
Upvotes: 3