菜鸟求助:替换一个字符串是用什么函数呀 ,还有 我想取字符串的还有 一个问题有一个字符串为‘abcdefg’ 我想取左边前三个字符,也就是abc我应该用什么函数呢

解决方案 »

  1.   

    StringReplace
    function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
      

  2.   

    StringReplace
    copy('abcdefg' ,0,3);
      

  3.   

    function leftstr(Const atext:string;acount:integer):string;
      

  4.   

    上面需要strutils单元,加在use里
      

  5.   

    function stringreplace(const s,Oldpattern,Newpattern:sting;flags:treplaceflags):string;
    单元:sysutils;
    flags包含rfreplaceall;不包含,仅替换s中首次出现的Oldpattern。