[Lazarus] use of function ExtractWord

John Landmesser jmlandmesser at gmx.de
Tue Sep 15 15:46:07 CEST 2015


Hi,

Example:

given a string:

str := '2015-09-14 14:46:50  downloadrate  (813 KB/s)'

if i want to get the first word ( worddelim is space ) i use:

Result := ExtractWord(1 ,str,['  ']);

Result is '2015-09-14'

That's clear :-))

But!

If i want to extract '(813 KB/s)', i have to extract the SECOND word!!

Result := ExtractWord(2 ,str,['( ', ')']);

Result is '813 KB/s'

My question:

Why do i have to extract the SECOND word? The word inside () occurs just 
once!

Delphi 5 delivers the same Result so i'm sure i misunderstand something?!!

lhelp tells me:
> ExtractWord extracts the N-th word from the string S. The set of 
> characters in WordDelims are used to mark word boundaries. A word is 
> defined as any non-empty sequence of characters which are not present 
> in WordDelims: if a
>
> character is not in WordDelims, it is considered as part of a word. If 
> an N-th word cannot be found, an empty string is returned.



Explanations are welcome.

Thanks!!








More information about the Lazarus mailing list