String:扩展
/** 为String类型的对象添加replaceAll方法 */
String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
} else {
return this.replace(reallyDo, replaceWith);
}
}
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
};
String.prototype.Ltrim = function() {
return this.replace(/(^\s*)/g, "");
};
String.prototype.Rtrim = function() {
return this.replace(/(\s*$)/g, "");
};