Einzelnen Beitrag anzeigen

chaoslion

Registriert seit: 1. Mär 2006
52 Beiträge
 
#8

Re: Wörter aus Memo extrahieren

  Alt 12. Jun 2007, 11:46
Hey,
hier wäre noch ne Möglichkeit:
Delphi-Quellcode:
procedure parseWords( const str: string; var tokens: TStringList );
var
  i: integer;
  buf: string;
  j: integer;
begin
  i := 1;
  
  while( i <= length(str) )do
  begin

    if( (ord(str[i]) <= 32) )then
    begin
      inc(i);
      continue;
    end
    else if( str[i] in ['A'..'z'] )then
    begin
      j := i;
      while( (i<= length(str)) and ((str[i] in ['A'..'z']) or (str[i] in ['0'..'9']) or (str[i] = '_') ) )do
        inc(i);
      buf := copy(str,j,i-j);
      tokens.Add(buf);
    end
    else
     inc(i);
  end;

end;
  Mit Zitat antworten Zitat