如何用Delphi实现StringTokenizer功能

发布时间:2021-12-28 13:11:12阅读:82382
如何用Delphi实现StringTokenizer功能:

  我们知道Java中有StringTokenizer,对于字符串处理都非常的方便,但是Delphi中没有提供该功能,我参考Java语言实现此功能的Delphi版本和C#版本。希望给大家提供一个方便。希望多多指教。zengqingsong@sohu.com     unit SkyStringTokenizer;   {字符串分析处理类  作者:曾青松  时间:2004/2/21(2003年除夕)   }     interface     uses   SysUtils, Classes;   type   IIterator = interface   function hasNext(): boolean;   function next(): string;   end;   type   TSkyStringTokenizer = class(TComponent, IIterator)   private   tokens: TStringList;   index: integer;   data: string;   delimiter: string;   procedure init(dataLine: string; delim: string);   function CharacterInTokens(ch: string; const sl: TStringList): boolean;   function StringToCharArray(delim: string): TStringList;   function SplitString(source, ch: string): Tstringlist;     protected   { Protected declarations }   public   { Public declarations }   constructor create(dataLine: string); overload;   constructor Create(dataLine: string; delim: string); overload;   destructor destroy();override;   function hasNext(): boolean;   function next(): string;

更多 0