FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades Extracting the lines from a text
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Extracting the lines from a text
Posted: Thu Sep 22, 2022 06:17 AM

Very nice code, thanks to José M.C. Quintas:

aList := hb_RegExSplit( hb_Eol(), cText )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Extracting the lines from a text
Posted: Thu Sep 22, 2022 06:21 AM

Another way:

hb_ATokens( cText, hb_Eol() )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Extracting the lines from a text
Posted: Thu Sep 22, 2022 06:57 AM

Thanks for the tip of using hb_regexSplit().
However hb_atokens() only accepts a single character for the delimiter.
So can't pass CRLF to it

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Extracting the lines from a text
Posted: Mon Sep 26, 2022 03:50 AM
hi,
hua wrote:However hb_atokens() only accepts a single character for the delimiter.
So can't pass CRLF to it


https://github.com/Petewg/harbour-core/wiki/hb_A#hb_atokenscstring-cdelimiterleol-lskipstrings-ldoublequoteonly--atokens
hb_ATokens(<cString>, [<cDelimiter>|lEOL], [<lSkipStrings>], [<lDoubleQuoteOnly>]) ➜ aTokens

returns an array filled with all individual tokens of given <cString> string, that is, all the separate sub-strings that are delimited by either <cDelimiter> or by EOL (end of line) if (instead of <cDelimiter>) <lEOL> has been passed and evaluates to .T.
If neither <cDelimiter> nor <lEOL> specified, then as delimiter is used, by default, an empty space (ASCII char 32).
greeting,

Jimmy
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Extracting the lines from a text
Posted: Mon Sep 26, 2022 07:00 AM
Thanks Jimmy.
Seems Harbour's documentation is a bit different than what I got from xHarbour Language Reference 1.1

HB_ATokens( <cString> , ;
[<cDelimiter>] , ;
[<lSkipQuotes>] , ;
[<lDoubleQuotesOnly>] ) --> aTokens

<cDelimiter>
A single character can be specified as delimiter used to tokenize the string <cString>. It defaults to a blank space (Chr(32)).
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion