반응형

var str = "Hi my name is hong Ill";
str = str.replace(/i/g,"X");
alert(str);

str 문자열 중 i를 모두 대문자X로 치환시킴
g : 전체 검색
※ g옆에 i를 넣을 경우 대소문자 구분 안하고 모두 치환 가능

str = str.replace(/i/gi,"X"); 

반응형
Posted by Hippalus
,