Absence operator is broken
kkos opened this issue · 2 comments
kkos commented
p /(?~ab)/.match("abc")
p /(?~abc)/.match("abc")
p /(?~ab|abc)/.match("abc")
=>
#<MatchData "a">
#<MatchData "ab">
#<MatchData "a">
But
p /(?~abc|ab)/.match("abc")
=>
#<MatchData "ab">
tonco-miyazawa commented
[PDF] Detail of this bug. ( in Japanese )
https://github.com/tonco-miyazawa/regex_etc/blob/master/MEMO_Onigmo/absense_bug_detai.pdf
hmmnrst commented
A very simple case is /(?~.*)/
. It should be equivalent to empty language ∅ (or /(?~)/
) because /.*/
matches to ""
and any string contains the empty string, but is not.
# Using Ruby 3.1.2
str = "abcdef"
p /(?~.*)/.match(str) #=> #<MatchData "abc">