Art and Commentary

String.prototype.trim()

Trim whitespace from a string in Javascript:

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

Added on Monday, June 15, 2009 at 11:07 pm in Code. Related posts about . Permalink

RSS Feeds
© 2010 John C. Covey.
WordPress