Delphi 获取带分隔符字符串中的字段值


本文整理自网络,侵删。

 

function GetFieldValue(separator: Char; strLine: string; nNum: Integer): string;
var
  Strs: TStrings;
  ResultStr: string;
begin
  Strs := TStringList.Create;
  Strs.Delimiter := separator;
  Strs.DelimitedText := strLine;
  if nNum > Strs.Count then
    ResultStr := ''
  else
    ResultStr := Strs[nNum - 1];
//delphitop.com
  FreeAndNil(Strs);
  Result := ResultStr;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Text:=GetFieldValue(',', '123,456,789', 3); //GetFieldValue('分隔符', '内容:123,456,789', 取值)
end;

相关阅读 >>

Delphi 类和对象

Delphi 设置webbrowser 代理服务器 与 useragent

Delphi xe5 json

Delphi 时间差函数及部分字符串与日期时间相互转换的函数

Delphi tms web core twebsocketclient

Delphi 将image组件的图片保存为jpg格式图片方法

Delphi 权限控制(Delphi tactionlist方案)

Delphi system.fillchar - 填充字节

Delphi 加密解密字符串函数

Delphi createmutex建立互斥对象,并且给互斥对象起一个唯一的名字

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



打赏

取消

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

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

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

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

评论

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