delphi 过滤开头 结尾 全部 空格的函数


本文整理自网络,侵删。

 
function TrimAnsi(const S: AnsiString): Ansistring;
var
  I, L: Integer;
begin
  L := Length(S);
  I := 1;
  while (I <= L) and (S[I] <= ' ') do Inc(I);
  if I > L then Result := '' else
  begin
    while S[L] <= ' ' do Dec(L);
    Result := Copy(S, I, L - I + 1);
  end;
end;

function TrimLeftAnsi(const S: AnsiString): AnsiString;
var
  I, L: Integer;
begin
  L := Length(S);
  I := 1;
  while (I <= L) and (S[I] <= ' ') do Inc(I);
  Result := Copy(S, I, Maxint);
end;

function TrimRightAnsi(const S: Ansistring): AnsiString;
var
  I: Integer;
begin
  I := Length(S);
  while (I > 0) and (S[I] <= ' ') do Dec(I);
  Result := Copy(S, 1, I);
end;

相关阅读 >>

Delphi 调用极光推送服务端http api实例

Delphi shellexecute打开文件另类用法

Delphi winapi: getwindowtext - 获取窗口标题

Delphi xe android platform uses-permission[1] 权限列表

Delphi 读写附加数据

Delphi win10系统通知 notificationcenter1 基本用法

Delphi getwindowhandle

Delphi2007-Delphi2010 程序不出现在任务栏的方法

Delphi checklistbox用法

Delphi firemonkey移动应用程序将设置保存到ini文件的示例

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...