Skip to content
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

Absence operator is broken #150

Open
kkos opened this issue Apr 26, 2020 · 2 comments
Open

Absence operator is broken #150

kkos opened this issue Apr 26, 2020 · 2 comments

Comments

@kkos
Copy link

kkos commented Apr 26, 2020

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
Copy link

[PDF] Detail of this bug. ( in Japanese )
https://github.com/tonco-miyazawa/regex_etc/blob/master/MEMO_Onigmo/absense_bug_detai.pdf

@hmmnrst
Copy link

hmmnrst commented Jun 15, 2022

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">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants