stString 문자열에서 stSource문자열을 stTarget문자열으로 변경시켜 줍니다.
UpperCase() 함수가 생각보다 속도가 느려 따로 변수를 잡아 계산하였습니다.
blClassification이 True면 대소문자를 구별하고, False면 구별하지 않습니다.
간단한 함수지만, 없으면 불편하고 만들기에는 귀찮은... --;
String __fastcall TForm1::StrReplace(String stString, String stSource, String stTarget, bool blClassification)
{
String stParse = "",
stUString = blClassification ? stString : stString.UpperCase(),
stUSource = blClassification ? stSource : stSource.UpperCase();
int itCount, itSourceLength = stSource.Length();
for(itCount = 1; itCount <= stString.Length(); itCount ++) {
if(stUString.SubString(itCount, itSourceLength) == stUSource) {
stParse += stTarget;
itCount += stSource.Length() - 1;
} else {
stParse += stString.SubString(itCount, 1);
}
}
return(stParse);
}
P.S : 빌더에서는 StringReplace 라는 함수를 쓰면 되네요.. 풀썩... ㅠ_ㅠ
|