String.prototype.EndWith = 함수(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length)
return false;
if (this.substring(this.length - str.length) == str)
return true;
else
return false;
return true;
}
String.prototype.StartWith = function (str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length)
return false;
if (this.substr(0, str.length) == str)
return true;
else
return false;
return true;
}
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.format = 함수(str) {
var i = 1, args = 인수;
var str = args[0];
var re = /{(d ) }/g;
return str.replace(re, function () { return args[i ] });
};
var Json2string = function (obj) {
var t = typeof ( obj);
if (t != "객체" || obj === null) {
// 단순 데이터 유형
if (t == "string") obj = "'" obj "'";
return String(obj);
}
else {
// 재귀 배열 또는 객체
var n, v, json = [], arr = (obj && obj.constructor == Array); for (n in obj) {
v = obj[n]; t = typeof (v);
if (t == "string") v = "'" v "'";
else if (t == "object" && v !== null)
v = Json2string(v);
json.push((arr ? "" : "'" n "':") String(v));
}
반환(arr ? "[" : "{") 문자열(json) (arr ? "]" : "}");
}
};