답변은 매우 간단해야합니다. 그러나 정규 표현식을 처음 사용합니다.정규 표현식을 사용하여 찾기 및 바꾸기
무엇 난 그냥 찾기 및 바꾸기되고 싶지 :
예를 : iti$%#[email protected]#ombina#$tion.43of//.45simp5./l7e5andsp75e$%cial23$#of%charecters
위의 문장에서 단어 "of"를 "in"로 바꿉니다
나는 이것을 시도했지만 결과를 얻지 못했습니다. 제발 도와주세요.
string="iti$%#[email protected]#ombina#$tion.43of//.45simp5./l7e5andsp75e$%cial23$#of%charecters";
var string2=string.replace("/(\w*\W*)of(\w*\W*)/g","$1in$2");
console.warn(string2);
감사합니다. + 1 @light 스타일 –
"단어"를 대체하지 않습니다. 완전한 단어가 아닐 때 "와"도 일치합니다. –