编写一个函数,对于给定的一个字符串,去掉其中不是英文字母的字符。要用基于DELPHI的开发语言或者PASCAL语言

解决方案 »

  1.   

    function filter(src: string): string;
    var
      i:integer;
    begin
      i:=1;
      while (src<>'') and (i<=length(src)) do
        if not (src[i] in ['a'..'z','A'..'Z'])
        then delete(src, i, 1)
        else inc(i);
      result:=src;
    end;
      

  2.   

    function TForm1.ExpString(Src: String): String;
    Var
      i:integer;
    begin
      For i:=0 to Length(Src) do
        if Src[i] in ['a'..'z','A'..'Z'] then  Result:=Result+Src[i];
    end;
      

  3.   

    function A(Str: string): string;
    var
      I, J: Integer;
    begin
      I := 0;
      J := 0;
      SetLength(Result, Length(Str));
      while I <= Length(Str) do
      begin
        if IsDBCSLeadByte(Byte(Str[I])) then
        begin
          Inc(I, 2);
          Continue;
        end;
        if (Str[I] in ['a'..'z','A'..'Z']) then
        begin
          Inc(J);
          Result[J] := Str[I];
        end;
        Inc(I);
      end;
      SetLength(Result, J);
    end;
      

  4.   

    请问楼上一句 
          inc()函数有什么功能?