Extracting the lines from a text

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Extracting the lines from a text

Post by Antonio Linares »

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

aList := hb_RegExSplit( hb_Eol(), cText )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Extracting the lines from a text

Post by Antonio Linares »

Another way:

hb_ATokens( cText, hb_Eol() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Extracting the lines from a text

Post by hua »

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
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Extracting the lines from a text

Post by Jimmy »

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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Extracting the lines from a text

Post by hua »

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
Post Reply