StringReplace(Source, Tag String , replace String, Option)

解决方案 »

  1.   

    var S: string;
    begin
      S := '   lkadjsf    lkasjlfajwlef';
      while Pos(' ', S) > 0 do
        S[Pos(' ', S)] := '&nbsp';
    end;
      

  2.   

    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.
      

  3.   

    例如:
    String1:=StringReplace(String1, ' ' , '&nbsp', rfReplaceAll);rfReplaceAll参数表示全部替换。
      

  4.   

    定义一个数组,读入每一个string的字符
    然后遍历一遍,如果为空就替换
      

  5.   

    var
    Str1:String;
    begin
    StrReplase(str1,' ','&nbsp')
    end.别忘了给分!