使用自定义分隔符分离字符串 解决Delphi7下TStringList.Delimiter分离无法跳过空格问题
2013-01-31 09:36
435 查看
{
函数功能:使用自定义分隔符分离字符串并以Stringlist返回
参数说明:
Source: 源字符串
Deli: 自定义分离符
StringList: 返回分离结果
}
procedure SplitString(Source,Deli:string; var StringList :TStringList);
var
EndOfCurrentString: Integer;
begin
if StringList = nil then exit;
StringList.Clear;
while Pos(Deli, Source)>0 do
begin
EndOfCurrentString := Pos(Deli, Source);
StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
end;
StringList.Add(source);
end;
// 调用
procedure TForm1.Button1Click(Sender: TObject);
var
strlist: TStringList;
begin
strlist := TStringList.Create;
SplitString('123,Channel 1,00000000000000000123,上下线,离线,2013-01-31 09:22:32,公司',
',',
strlist);
ShowMessage(strlist.Text);
end;
函数功能:使用自定义分隔符分离字符串并以Stringlist返回
参数说明:
Source: 源字符串
Deli: 自定义分离符
StringList: 返回分离结果
}
procedure SplitString(Source,Deli:string; var StringList :TStringList);
var
EndOfCurrentString: Integer;
begin
if StringList = nil then exit;
StringList.Clear;
while Pos(Deli, Source)>0 do
begin
EndOfCurrentString := Pos(Deli, Source);
StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
end;
StringList.Add(source);
end;
// 调用
procedure TForm1.Button1Click(Sender: TObject);
var
strlist: TStringList;
begin
strlist := TStringList.Create;
SplitString('123,Channel 1,00000000000000000123,上下线,离线,2013-01-31 09:22:32,公司',
',',
strlist);
ShowMessage(strlist.Text);
end;
相关文章推荐
- 使用自定义分隔符分离字符串 解决Delphi7下TStringList.Delimiter分离无法跳过空格问题
- 关于使用Volley下载的json字符串无法显示中文的问题(已解决)
- 在使用Gson的toJson()方法转为json字符串的时候无法显示中文和符号的问题(已解决)
- 解决.NET Core中MailKit无法使用阿里云邮件推送服务的问题
- vue前后端分离使用fetch 跨域请求时 session失效问题解决
- 解决iostat 无法使用的问题
- 在线聊天项目1.4版 使用Gson方法解析Json字符串以便重构request和response的各种请求和响应 解决聊天不畅问题 Gson包下载地址
- 解决centos5系统不受支持yum无法使用的问题
- thinkphp使用view的时候无法利用phpexcel导出数据问题的解决
- "无法使用前导.. 在顶级目录上退出"问题的解决
- "无法删除数据库,因为该数据库当前正在使用"问题解决
- 用流的方法解决“文件正由另一进程使用,因此该进程无法访问该文件” 的问题 FileStream
- 解决Ubuntu下无法使用Wireshark抓包的问题
- 解决在log4net 中使用sqlite 无法加载“SQLite.Interop.066.DLL ”的问题
- 解决msgfmt无法使用的问题
- 解决“使用svn时,无法连接maven仓库”的问题。
- 64位操作系统使用PLSQL Developer时,“无法解析指定的连接标识符”问题的解决办法
- 解决Windows x64bit环境下无法使用PLSQL Developer连接到Oracle DB中的问题
- Android studio 使用AIDL 无法import class问题解决
- 解决Django模板无法使用perms变量问题的方法