Javascript String collapseWhitespace()

Description

Javascript String collapseWhitespace()


String.prototype.collapseWhitespace = function() {
  var s = this.replace(/[\s\xa0]+/g, ' ').replace(/^\s+|\s+$/g, '');
  return s;/*  ww  w .j  a v a  2s . co m*/
};



PreviousNext

Related