Art and Commentary

June 15th, 2009

Trim whitespace from a string in Javascript:

  String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
  }

Test test testing

RSS Feeds
© 2010 John C. Covey.
WordPress