var oldStr='//dad/////dadasdasd/////////asdasdads/' var newStr = oldStr.replace(/\/{2,}/g,'/') alert(newStr)