-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty regular expression matches (fix #2565) #2677
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")'
22 Fine, 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.