My regex fails under Harbour

My regex fails under Harbour

Postby hua » Fri Nov 04, 2022 10:21 am

Any idea why I get .f. for all of these under Harbour?
Code: Select all  Expand view

#include "fivewin.ch"
proc main()
? hb_isregex("\d")
? hb_isregex("\d+")
? hb_isregex("[0-9]")
return
 
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: My regex fails under Harbour

Postby cnavarro » Fri Nov 04, 2022 12:32 pm

hua wrote:Any idea why I get .f. for all of these under Harbour?
Code: Select all  Expand view

#include "fivewin.ch"
proc main()
? hb_isregex("\d")
? hb_isregex("\d+")
? hb_isregex("[0-9]")
return
 


Please, try
Code: Select all  Expand view

#include "fivewin.ch"
proc main

   local pRegx
   pRegx := HB_RegExComp( "\d" )
   ? hb_isregex( pRegx )
   //
return
 

HB_IsRegEx( <uExp> ) → <lIsCompRegEx>
Tells if <uExp> is a compiled regular expression compiled with HB_RegExComp()
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: My regex fails under Harbour

Postby hua » Mon Nov 07, 2022 2:12 am

Thanks Cristobal.
The sentence now works in my standalone test but not my module.
Is there anyway to check where the linker is pulling hb_regex() from? It seems suspicious that I get an empty array when there is no match instead of NIL
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: My regex fails under Harbour

Postby cnavarro » Mon Nov 07, 2022 11:48 am

Dear Hua
Please look description this functions
https://www.kresin.ru/en/hrbfaq_3.html#Doc9
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: My regex fails under Harbour

Postby hua » Tue Nov 08, 2022 3:14 am

Thanks Cristobal.
If under Harbour hb_regex() returns an empty array when no match is found then it is different from xHarbour. From xHarbour Language Reference Guide 1.1
Return
The function returns an array filled with the found substrings matching the regular expression. If no match is found, the return value is NIL.


Thanks for pointing that out.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: My regex fails under Harbour

Postby hua » Wed Nov 09, 2022 2:22 am

Just an update. The problematic regex problem went away when I rearranged libs (the bold part) to be linked from

j:\harbour\bcc7\lib\cw32.lib +
j:\harbour\bcc7\lib\import32.lib +
j:\harbour\bcc7\lib\uuid.lib +
j:\harbour\bcc7\lib\ws2_32.lib +

j:\harbour\hbcc7\lib\win\bcc\hbcpage.lib +
j:\harbour\hbcc7\lib\win\bcc\hbcplr.lib +
j:\harbour\hbbc7\lib\win\bcc\hbct.lib +
j:\harbour\hbbc7\lib\win\bcc\hbpcre.lib +
j:\harbour\hbbc7\lib\win\bcc\hbnf.lib +
j:\harbour\hbbc7\lib\win\bcc\xhb.lib +
j:\harbour\hbbc7\lib\win\bcc\hbziparc.lib +
j:\harbour\hbbc7\lib\win\bcc\hbmzip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbzlib.lib +
j:\harbour\hbbc7\lib\win\bcc\minizip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbusrrdd.lib +
j:\harbour\hbbc7\lib\win\bcc\hbtip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbzebra.lib +
j:\harbour\bcc7\lib\psdk\odbc32.lib +


to

j:\harbour\hbcc7\lib\win\bcc\hbcpage.lib+
j:\harbour\hbcc7\lib\win\bcc\hbcplr.lib+
j:\harbour\hbbc7\lib\win\bcc\hbct.lib +
j:\harbour\hbbc7\lib\win\bcc\hbpcre.lib +
j:\harbour\hbbc7\lib\win\bcc\hbnf.lib +
j:\harbour\hbbc7\lib\win\bcc\xhb.lib +
j:\harbour\hbbc7\lib\win\bcc\hbziparc.lib +
j:\harbour\hbbc7\lib\win\bcc\hbmzip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbzlib.lib +
j:\harbour\hbbc7\lib\win\bcc\minizip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbusrrdd.lib +
j:\harbour\hbbc7\lib\win\bcc\hbtip.lib +
j:\harbour\hbbc7\lib\win\bcc\hbzebra.lib +
j:\harbour\bcc7\lib\cw32.lib +
j:\harbour\bcc7\lib\import32.lib +
j:\harbour\bcc7\lib\uuid.lib +
j:\harbour\bcc7\lib\ws2_32.lib +

j:\harbour\bcc7\lib\psdk\odbc32.lib +


Now I'm only left with the perplexing issue of the linker not finding hbcpage.lib and hbcplr.lib even though in the link script the full path was written and I checked to make sure they exist. For the time being I'm forced to copy both of the libs into where my source is
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

Re: My regex fails under Harbour

Postby Antonio Linares » Wed Nov 09, 2022 8:47 am

thanks for sharing it :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests