On Tue, 15 Sep 2015, John Landmesser wrote:

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!

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)

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to