比如:我有一个字符串gkdxxx小乖xxx小乖,我想
把所有小乖换成xg,请问用什么样的函数?

解决方案 »

  1.   

    StringReplace(s,'小乖','xg',[rfReplaceAll]);
      

  2.   

    wjlsmail说的对,这个方法很好。我用过。
      

  3.   

    Returns a string with occurrences of one substring replaced by another substring.UnitSysUtilsCategorystring handling routinesDelphi syntax:function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;C++ syntax:extern PACKAGE AnsiString __fastcall StringReplace(const AnsiString S, const AnsiString OldPattern, const AnsiString NewPattern, TReplaceFlags Flags);DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string may contain Multibyte characters.S is the source string, whose substrings are changed.OldPattern is the substring to locate and replace with NewPattern.NewPattern is the substring to substitute for occurrences of OldPattern.Flags is a set of flags that govern how StringReplace locates and replaces occurrences of OldPattern. If Flags does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, StringReplace replaces all instances of OldPattern with NewPattern. If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.