請問VB有個function叫Replace,那麼Delphi有沒有類似的function |
答題得分者是:channel
|
SuperLowB
初階會員 發表:96 回覆:77 積分:34 註冊:2003-06-11 發送簡訊給我 |
|
channel
尊榮會員 發表:67 回覆:707 積分:854 註冊:2002-05-02 發送簡訊給我 |
引言: 如題您使用StringReplace這個funciotn試試看。 type TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase); function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string; rfReplaceAll:全部置換 rfIgnoreCase:勿略大小寫 For Example: var aStr: String; begin aStr := 'This is a book, not a pen!'; ShowMessage(StringReplace(aStr, 'a', 'two', []));//變為This is two book, not a pen!只替換了第一個符合的字 ShowMessage(StringReplace(aStr, 'a', 'two', [rfReplaceAll]));//變為This is two book, not two pen!替換了所有符合的字 aStr := 'This is a book, not A pen!'; ShowMessage(StringReplace(aStr, 'a', 'two', [rfReplaceAll]));//變為This is two book, not A pen!只替換了符合的字(小寫a) ShowMessage(StringReplace(aStr, 'a', 'two', [rfReplaceAll, rfIgnoreCase]));//變為This is two book, not two pen!不管大小寫替換了所有符合的字 end;~小弟淺見,參考看看~ 發表人 - channel 於 2003/07/08 17:36:39
------
~小弟淺見,參考看看~ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |