str.replace(/foo/g, "bar")

or

String.prototype.replaceAll = function(str1, str2, ignore) {
 return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,"\\$&"),(ignore?"gi":"g")),(typeof(str2)=="string")?str2.replace(/\$/g,"$$$$"):str2);
}


http://hangaebal.blogspot.kr/2014/06/javascript-string-replaceall.html
http://stackoverflow.com/questions/2116558/fastest-method-to-replace-all-instances-of-a-character-in-a-string


'Blogger 이사' 카테고리의 다른 글

[Servlet] Servlet 구동 기본  (0) 2016.01.14
[JavaScript] '초' -> '시 분 초' 형태로  (0) 2016.01.14
[SQLite] Web SQL search on dates  (0) 2016.01.14
[SQLite] SQLite Syntax Documentation  (0) 2016.01.14
[SQLite]Web SQL error handling  (0) 2016.01.14

+ Recent posts