js String 方法
时间:2010-07-19 来源:kaivsj
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, "");
}
String.prototype.htmlEncode = function() {
return this.replace(/&/g, "&").replace(/>/g, ">").replace(/</g,
"<").replace(/"/g, """);
}
String.prototype.htmlDecode = function() {
return this.replace(/&/g, "&").replace(/>/g, ">").replace(/</g,
"<").replace(/"/g, '"');
}
相关阅读 更多 +










