zoukankan      html  css  js  c++  java
  • Split string in Delphi

    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;
  • 相关阅读:
    Linux IO模型漫谈(3) 阻塞式IO实现
    Linux IO模型漫谈(4) 非阻塞IO
    Linux IO模型漫谈(6) 信号驱动IO模型
    Go语言_反射篇
    Linux IO模型漫谈(5) IO复用模型之select
    Go语言_函数学习篇
    Go语言_接口篇
    nginx源码学习Unix Unix域协议
    Java GC
    Heritrix 3.1.0 源码解析(三十四)
  • 原文地址:https://www.cnblogs.com/larson/p/2733776.html
Copyright © 2011-2022 走看看