Posted By

desmond54 on 02/14/10


Tagged

javascript


Versions (?)

Trim String Prototype


 / Published in: JavaScript
 

  1. String.prototype.trim = function() {
  2. // skip leading and trailing whitespace
  3. // and return everything in between
  4. var trimmedString = this;
  5. trimmedString = trimmedString.replace(/^\s+/,"");
  6. trimmedString = trimmedString.replace(/\s+$/,"");
  7. return trimmedString;
  8. }

Report this snippet  

You need to login to post a comment.