鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > delphi > >

Split string in Delphi

来源:互联网 作者:佚名 时间:2012-11-15 13:20
There is no function like String.Split(C# does have) in Delphi. So if you need to split a string, you can use TStringList to finish this work. With the code bellow, we can does split a string with a char. 1: function Split(aStrInput: strin

There is no function like String.Split(C# does have) in Delphi.

So if you need to split a string, you can use TStringList to finish this work.

With the code bellow, we can does split a string with a char.

1: function Split(aStrInput: string; aChrDelimiter: char): array of string; 2: var 3: lstSplit: TStringList; 4: arrResult: array of string; 5: begin 6: lstSplit := TStringList.Create; 7: SetLength(arrResult, 3); 8: lstSplit.Delimiter := ':'; 9: lstSplit.DelimitedText := aStrInput; 10: arrResult[0] := lstSplit.Strings[0]; 11: arrResult[1] := lstSplit.Strings[1]; 12: arrResult[2] := lstSplit.Strings[2];

13: Result := arrResult;

14: FreeAndNil(lstSplit);

15: end; ,免备案空间香港虚拟主机服务器空间
上一篇:没有了
下一篇:delphi OnMouseLeave 事件不灵敏及解决之道
网友评论
<