Board index » cppbuilder » Remy..need help on your (delete from-to) string function
Oren Halvani
![]() CBuilder Developer |
Remy..need help on your (delete from-to) string function2004-06-02 06:52:25 AM cppbuilder56 hi Remy and all the others, last time you gave me the below function that deletes strings from - to my question now: how is it possible to make this function working Case-Sensitive ?? i know i have to set the TSearchTypes Options to "stMatchCase" but how ecactly can I declare that?? i tried... TSearchTypes Options << stMatchCase; // WHAT IS WRONG HERE ??? TSearchTypes Options() = stMatchCase; // also didn't worked...... Oren here is your function... /*****************************************************/ void __fastcall DeleteFromTo(TRichEdit *re, const AnsiString &Begin, bool ReplaceBegin, const AnsiString &Ende, bool ReplaceEnde, const AnsiString &ReplaceText) { re->Lines->BeginUpdate(); try { TSearchTypes Options; int BeginLen, EndeLen, ReplaceLen, Start, End, Laenge; BeginLen = Begin.Length(); EndeLen = Ende.Length(); ReplaceLen = ReplaceText.Length(); Start = re->FindText(Begin, 0, re->GetTextLen(), Options); while(Start>-1) { End = re->FindText(Ende, Start + BeginLen,re->GetTextLen() - (Start + BeginLen), Options); if(End == -1) break; if(!ReplaceBegin) Start += BeginLen; if(ReplaceEnde) End += EndeLen; Laenge = (End - Start); if(Laenge>0) { re->SelStart = Start; re->SelLength = Laenge; re->SelText = ReplaceText; } Start = re->FindText(Begin, Start + ReplaceLen,re->GetTextLen() - (Start + ReplaceLen), Options); } } __finally { re->Lines->EndUpdate(); } } |