프로그램/script
javascript string extend function
mulderu
2011. 2. 1. 13:55
오랜만에 javascript string 을 ...
String.prototype.toHtml = function (){
return this.replace(new RegExp("<", "g"), "<")
.replace(new RegExp(">", "g"), ">")
.replace(new RegExp("\"", "g"), """);
};
String.prototype.toText = function (){
return this.replace(new RegExp("<br>", "ig"), "\r\n")
.replace(new RegExp("<", "ig"), "<")
.replace(new RegExp(">", "ig"), ">")
.replace(new RegExp("&", "ig"), "&");
};