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

Some regex quantifiers don't work as expected #2112

Open
jmaslak opened this issue Jul 22, 2018 · 3 comments
Open

Some regex quantifiers don't work as expected #2112

jmaslak opened this issue Jul 22, 2018 · 3 comments
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@jmaslak
Copy link
Contributor

jmaslak commented Jul 22, 2018

The Problem

This regex, demonstrated here, returns true when it shouldn't (I think!).

This is a golfed exampe -

perl6 -e 'say "aaa" ~~ m/(a ** {2..*}) ** 2..*/'

Output:

[0] red:jmaslak$ perl6 -e 'say "aaa" ~~ m/(a ** {2..*}) ** 2..*/'
「aaa」
 0 => 「a」
 0 => 「aa」
[0] red:jmaslak$

Note perl6 -e 'say "aaa" ~~ m/(a ** 2..*) ** 2..*/' does what I would expect it to do (returns false). So does perl6 -e 'say "aaa" ~~ m/(a ** 2..*) ** {2..*}/'

Expected Behavior

Expected behaviro is returning false.

Actual Behavior

Returns a true value.

Steps to Reproduce

perl6 -e 'say "aaa" ~~ m/(a ** {2..*}) ** 2..*/'

Environment

  • Operating system: Ubuntu 16.04
  • Compiler version (perl6 -v): 2008.06 6.c
@ugexe
Copy link
Member

ugexe commented Jul 22, 2018

It works with the :ratchet adverb. So probably a result of { } ( See the answer here )

@lizmat
Copy link
Contributor

lizmat commented Jul 26, 2018

So, can we close this ticket? Or should we work on documentation?

@jnthn
Copy link
Member

jnthn commented Jul 26, 2018

@lizmat No, I think it's a backtracking bug, and :ratchet doesn't do backtracking, so "hides" the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules
Projects
None yet
Development

No branches or pull requests

5 participants