Posted By

kayue on 01/10/10


Tagged

trim


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dancrew32
nerdfiles


Trim


 / Published in: JavaScript
 

URL: http://lifesinger.org/blog/2010/01/fastest-javascript-trim/

  1. if(!String.prototype.trim) {
  2. var TRIM_REG = /^\s+|\s+$/g;
  3. String.prototype.trim = function() { return this.replace(TRIM_REG, ''); }
  4. }

Report this snippet  

You need to login to post a comment.