zoukankan      html  css  js  c++  java
  • 将固定字符分隔的内容转换为数组

     1 function Split(const Source, ch: string): TStringList;
     2 var
     3   Temp: string;
     4   I: Integer;
     5   chLength: Integer;
     6   tmpStr: string;
     7 begin
     8   Result := TStringList.Create;
     9   //如果是空自符串则返回空列表
    10   if Source = '' then Exit;
    11   Temp := Source;
    12   I := Pos(ch, Source);
    13   chLength := Length(ch);
    14   while I <> 0 do
    15   begin
    16     tmpStr := Copy(Temp, 0, I - chLength + 1);
    17     if tmpStr[Length(tmpStr)] = ch then
    18       tmpStr := Copy(tmpStr, 0, Length(tmpStr) - 1);
    19     Result.Add(tmpStr);
    20     Delete(Temp, 1, I - 1 + chLength);
    21     I := pos(ch, Temp);
    22   end;
    23   Result.add(Temp);
    24 end;
    此代码来源于网上,因需要稍做修改。感谢原作者
  • 相关阅读:
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    教你搭建SpringSecurity3框架(附源码)
    浅谈数据库联合查询
  • 原文地址:https://www.cnblogs.com/wjhx/p/2041837.html
Copyright © 2011-2022 走看看