It looks like the 2nd last line in the j8 version is the one that corrected _1 
0 for unmatched entries.

Not sure why it was changed/rewritten, but its probably important to keep 
consistent results?

If not, has it been decided that this new behaviour is better and should stay?






On Sunday, May 3, 2020, 11:19:04 a.m. EDT, 'Pascal Jasmin' via Beta 
<[email protected]> wrote: 





from j806

rxmatch_jregex_

4 : 0

if. lb=. 32 = 3!:0 x do. ph=. >0{x else. ph=. x end.

if. cx=. 2 = 3!:0 ph do. hx=. rxcomp ph

else. rxlastxrp=: > 1{((hx=. ph) - 1) ({"1) rxpatterns end.

nsub=. rxnsub rxlastxrp

rxlastrc=: >0{rv=. jregexec rxlastxrp ; (,y) ; rxms ; ((2*rxms)$_1 0) ; 0

if. cx do. rxfree hx end.

m=. (nsub,2)$>4{rv

t=. (0{"1 m)

m=. t,.-~/"1 m

m=. _1 0 ((t=_1)#i.#t)} m

if. lb do. (>1{x){ m else. m end.

)

in J9

  rxmatch_jregex_

4 : 0

'p n'=. 2 {. boxopen x

regcomp p

r=. regmatch1 y

if. #n do. n{r end.

)

regcomp_jregex_

3 : 0

if. -.ischar y do. reghandle y return. end.

if. (0<#y) *. y-:lastpattern do. return. end.

regfree''

lastpattern=: y

msg=. ,2

off=. ,2

flg=. PCRE2_MULTILINE*RX_OPTIONS_MULTILINE

lastcomp=: 0 pick rc=. jpcre2_compile (,y);(#y);flg;msg;off;<<0

'msg off'=. 4 5{rc

if. 0=lastcomp do. regerror msg,off end.

lasthandle=: 0

lastmatch=: 0 pick jpcre2_match_data_create_from_pattern (<lastcomp);<<0

lastnsub=: 0 pick jpcre2_get_ovector_count <<lastmatch

EMPTY

)

one pattern where it fails,

   '\A[[:alpha:]][[:alnum:]_]+([\.:]+)\Z'&rxmatch every ;: '( + ` - ) gg.'  
NB.j806 "correct result"

_1 0

_1 0




_1 0

_1 0




_1 0

_1 0




_1 0

_1 0




_1 0

_1 0




0 3

2 1


9.01 incorrect result (2nd rows 0 0 instead of _1 0 for words that don't end in 
.: punctuation and at least 2 chars long)

_1 0

0 0




_1 0

0 0




_1 0

0 0




_1 0

0 0




_1 0

0 0




0 3

2 1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to