delphi中有无和php中Explode()类似的函数?

Hylwr 2005-04-14 10:58:39
php中的explode函数很方便,能将“a,b,c”或“a/b/c”中被格开的字符单独提取出来,不知道Delphi中有无类似的函数?
...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
何鲁青 2005-04-14
  • 打赏
  • 举报
回复
影响中没有,要自己写函数
不过也不难...
linzhengqun 2005-04-14
  • 打赏
  • 举报
回复
用Copy和Pos自己写一个。

function GetString(SrcStr, SprStr: String): String;
var Index: Integer;
begin
Result:= '';
while True do
begin
Index:= Pos(SprStr, SrcStr);
if Index = 0 then
begin
Result:= Result + SrcStr;
Break;
end;
Result:=Result + Copy(SrcStr, 1, Index - 1);
SrcStr:= Copy(SrcStr, Index + Length(SprStr), Length(SrcStr));
end;
end;

procedure TForm1.A1Click(Sender: TObject);
begin
Edit2.Text:= GetString(Edit1.Text, ',');
end;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧