2009/02/20 14:14
CodeIN/Web
The JavaScript function for String Replace replaces the first occurrence in the string. The function is similar to the php function str_replace and takes two simple parameters. The first parameter is the pattern to find and the second parameter is the string to replace the pattern with when found. The javascript function does not Replace All...
str = str.replace(”find”,”replace”)
To ReplaceAll you have to do it a little differently. To replace all occurrences in the string, use the g modifier like this:
str = str.replace(/find/g,”replace”)
str = str.replace(”find”,”replace”)
To ReplaceAll you have to do it a little differently. To replace all occurrences in the string, use the g modifier like this:
str = str.replace(/find/g,”replace”)
'CodeIN > Web' 카테고리의 다른 글
| [jsp]forward (0) | 2009/03/08 |
|---|---|
| [javascript] confirm 사용법 (2) | 2009/03/01 |
| JavaScript String Replace All (3) | 2009/02/20 |
| [javascript] dynamic 테이블 생성시 event 추가 하는 방법 (0) | 2009/02/18 |
| [javascript] checkbox 활성화/비활성화 (0) | 2009/02/16 |
| [javascript] checkbox에 체크된 row만 삭제 하기 (0) | 2009/02/13 |


