code: function detab(text) {
  
          text = text.replace(/\t(?=\t)/g,"    ");
          text = text.replace(/\t/g,"~A~B");
          text = text.replace(/~B(.+?)~A/g, function(wholeMatch,m1,m2) {
  
              var leadingText = m1;
              var numSpaces = 4 - leadingText.length % 4;
  
              for(var i=0; i<numSpaces; i++) {
                  leadingText+=" ";
              }
  
              return leadingText;
          });
  
          text = text.replace(/~A/g,"    ");
          text = text.replace(/~B/g,"");
  
          return text;
      }
docs: }}} {{{ detab