var str ="sdfvadsvadsaaasdfvsdassssvweswwwWWWwwvdsvsssssddddfffff"; var reg = /(\w)\1+/g; var a,max=[""]; while((a = reg.exec(str)) != null){ if(max[0].length < a[0].length){ max[0] = a[0] }else if(max[0].length == a[0].length){ max.push(a[0]) } } console.log(max)