Monday, May 4, 2009

two useful String extend functions.


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

String.prototype.addslashes = function () {
return this.replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}

No comments:

Post a Comment