delphi 简单的删除字符串尾部数字的代码

 

 delphi  简单的删除字符串尾部数字的代码

方式一:

function FilterShowName(const sName: String): String;
var
  I: Integer;
begin
  Result := sName;
  if Result <> '' then
  begin
    for I := Length(Result) downto 1 do
    begin
      if Result[I] in ['0'..'9', '-'] then
        Delete(Result, I, 1)
      else
        Break;
    end;
  end;
end;

方式二(未测试):

function GetChinese(S :string):string;
var
  i,Temp :integer;
begin
  Result := '';
  i := 1;
  while i<Length(S) do
  begin
    if ord(S[i])<$A1 then
      i := i + 1
    else begin
      Temp := ord(S[i]);
      Temp := Temp shl 8;
      Temp := Temp + ord(S[i]);
      if Temp>$B0A0 then
        Result := Result + S[i]+S[i+1];
      i := i + 2;
    end;
  end;
end;

 

posted on 2016-10-28 17:18  red_red_red  阅读(689)  评论(0编辑  收藏  举报

导航