Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
photo of Zarko Gajic

Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming since 1998

How to Split a Delphi String to Words / Tokens

Saturday June 28, 2008
in Delphi TIPS :: GetNextToken returns the next token (substring) from a string, starting at an index and ending 1 character before the next occurrence of a Separator.
Split breaks a string containing designated separators into tokens and adds them to a string list.
AddToken joins 2 strings with a separator character between.

Read the full article to get the code to Split a Delphi String to Words / Tokens.

Related:

Comments

June 29, 2008 at 7:10 am
(1) Olaf Monien says:

Your proposed functions certainly offer quite some flexibility, but I still think it’s worth mentioning that there is a fairly easy to use Tokenizer in the box already:

uses HTTPUtil;

procedure TForm22.Button1Click(Sender: TObject);
var
LTokenizer: IStringTokenizer;
begin
Memo1.Clear;
LTokenizer := StringTokenizer(Edit1.Text, ‘ ‘);
while LTokenizer.hasMoreTokens do
Memo1.Lines.Add(LTokenizer.nextToken);
end;

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Delphi Programming

About.com Special Features

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.