打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
function SplitString(const Source, ch: string): TStringList;
{调用时,外部的stringlist不要create,使用strlist =SplitString()来调用,调用者自己负责
 把stringlist free掉 }

function SplitString(const Source, ch: string): TStringList;
var
  temp, s: string;
  i, len: Integer;
begin
//如果是空自符串则返回空列表
  Result := TStringList.Create();
  if length(Source) * length(ch) = 0 then
    exit;
  temp := Source;
  i := pos(ch, Source);
  if i = 0 then
    exit;

  len := length(ch);
  while i <> 0 do
  begin
    s := copy(temp, 0, i - 1);
    Result.add(s);
    {从位置1开始删除,删除i+len-1个}
    Delete(temp, 1, i + len - 1);
    i := pos(ch, temp);
  end;
  Result.add(temp);
end;
{------------------------------------------------------------------------------}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
让二维条码扫描器具有识别汉字的能力(delphi)
JS过滤空格
Delphi中的THashedStringList对象
(EXCEL)小写金额转换为中文大写金额
JavaScript实现的几种排序
如何将字符串转换为相应的整型
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服