'replaceAll'에 해당되는 글 1건

  1. 2008.06.27 Javascript에서 replaceAll by UrC9 3
자바스크립트는 'replaceAll'이 없다.
그래서 만든 꼼수

function replaceAll(str, searchStr, replaceStr) {
 while (str.indexOf(searchStr) != -1) {
  str = str.replace(searchStr, replaceStr);
 }
 return str;
}

사용 할 땐

str = repalceAll(str, "<", "&lt;");

뭐 이런식?
Posted by UrC9
,