Fix empty regular expression matches (fix #2565)#2677
Fix empty regular expression matches (fix #2565)#2677nicowilliams merged 1 commit intojqlang:masterfrom
Conversation
|
@itchyny - Congratulations! You could remove the disclaimer at onig.test:91 |
56f01a9 to
1eaa90f
Compare
|
Thanks! |
I think that is a bug, it should emit |
|
Why? Empty regex matches every character boundaries. Easier example is |
|
@itchyny |
No. @itchyny and (not surprisingly :-) gojq are correct. In any case, gsub relies (and ought to rely) on |
|
I was used to the sed behaviour where |
|
$ jq -n '"1111" | gsub("1*";"2")'
2
$ ./jq -n '"1111" | gsub("1*";"2")'
22Fine, I guess |
As reported by #2565,
"ab" | match(""; "g")should yield 3 matches at offset 0, 1, and 2. Fixing this behavior also fixes"a" | gsub(""; "a")to emit"aaa"not"aa". Fixes #2565.