Extracting the lines from a text

Extracting the lines from a text

Postby Antonio Linares » Thu Sep 22, 2022 6:17 am

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: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Extracting the lines from a text

Postby Antonio Linares » Thu Sep 22, 2022 6:21 am

Another way:

hb_ATokens( cText, hb_Eol() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Extracting the lines from a text

Postby hua » Thu Sep 22, 2022 6: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Extracting the lines from a text

Postby Jimmy » Mon Sep 26, 2022 3: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
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Extracting the lines from a text

Postby hua » Mon Sep 26, 2022 7: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 4 guests