I try to replace some multiple strings with an abbreviation ...
If a string occurrences more than 2 times then it is to replace with string..string.
E.g. the string is as follows:
var str = 'i,u,br,br,p,p,p,p,br,br,br,br,div,div,div,div,br,br,br,p';
// The result should be as follows:
str = 'i,u,br,br,p..p,br..br,div..div,br..br,p';
Here is my approach, but it doesn't work proper:
str = str.replace(/((,\w+)){3,}/igm, ',$1...$1');
Do you have any idea how can I do it right? Thanks.