[Lazarus] use of function ExtractWord
Michael Van Canneyt
michael at freepascal.org
Tue Sep 15 15:50:45 CEST 2015
On Tue, 15 Sep 2015, John Landmesser wrote:
> 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 :-))
> 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
Because you cannot specify separate begin and end separator, just 'separators'.
( is a separator, so everything before ( is the first word.
if you specify ( ) as separators, there are 3 positions in the text:
before (, between ( and ) and after ).
(the last one is empty)
More information about the Lazarus