void festring::SearchAndReplace(festring& Where, const festring& What, const festring& With, sizetype Begin) { for(sizetype Pos = Where.Find(What, Begin); Pos != NPos; Pos = Where.Find(What, Pos)) { Where.Erase(Pos, What.GetSize()); Where.Insert(Pos, With); } }
void festring::SearchAndReplace(festring& Where, cfestring& What, cfestring& With, sizetype Begin) { if(What.IsEmpty()) ABORT("Infinite loops in SearchAndReplace detected!"); for(sizetype Pos = Where.Find(What, Begin); Pos != NPos; Pos = Where.Find(What, Pos)) { Where.Erase(Pos, What.GetSize()); Where.Insert(Pos, With); Pos += With.GetSize(); } }
void festring::SplitString(festring& Source, festring& Result, sizetype Length) { if(Source.GetSize() <= Length) { Result << Source; Source.Empty(); return; } sizetype Pos = Source.FindLast(' ', Length); if(Pos != NPos) { Result.Append(Source, Pos); Source.Erase(0, Pos + 1); } else { Result.Append(Source, Length); Source.Erase(0, Length); } }