Javascript String replaceAll(regExp, replaceStr)

Description

Javascript String replaceAll(regExp, replaceStr)


String.prototype.replaceAll = function(regExp, replaceStr)
{
      var ori = this;
            //  w  w w.  j  ava2 s .  c o  m
      while(true)
      {
            if(ori.indexOf(regExp) < 0)
            {
                  break;
            }
 
            ori = ori.replace(regExp, replaceStr);
      }
 
      return ori;
}



PreviousNext

Related