javascript trim / javascript replaceAll
String.prototype.replaceAll = function(org,dest) {
return this.split(org).join(dest);
}
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, “”);
}
프로토타입을 변경하고 싶지 않다면 아래와 같이 써도 되겠다.
function replaceAllString(str, org, dest) {
return str.split(org).join(dest);
}
function trimString(str) {
return str.replace(/(^\s*)|(\s*$)/g, “”);
}