-
Notifications
You must be signed in to change notification settings - Fork 174
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
Incorrect results for repeat operators #56
Comments
Hi @kkos and thanks for the notice 👍 Could you please provide some code so I can be certain what cases we are talking about. Could you perhaps make a PR editing some of https://github.com/kokke/tiny-regex-c/blob/master/tests/test1.c to showcase exactly the cases you're talking about in 1) 2) ? That would help me understand your issue :) |
I don't even know if it supports nested repeat operators in the first place, so I'll refrain from writing a PR. { OK, "a?", "", (char*) 0 },
{ OK, "a?", "a", (char*) 0 },
{ OK, "a*", "", (char*) 0 },
{ OK, "a??", "a", (char*) 0 },
{ OK, "a?*", "a", (char*) 0 },
{ OK, "a?+", "a", (char*) 0 },
{ OK, "a*?", "a", (char*) 0 },
{ OK, "a**", "a", (char*) 1 },
{ OK, "a*+", "a", (char*) 1 },
{ OK, "a+?", "a", (char*) 0 },
{ OK, "a+*", "a", (char*) 1 },
{ OK, "a++", "a", (char*) 1 }, The Python code I tested: #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
# (1)
print(re.match(r'a??', ""))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'a??', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'a*', ""))
#=> <re.Match object; span=(0, 0), match=''>
# (2)
print(re.match(r'(?:a??)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'(?:a??)*', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'(?:a??)+', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'(?:a*)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'(?:a*)*', "a"))
#=> <re.Match object; span=(0, 1), match='a'>
print(re.match(r'(?:a*)+', "a"))
#=> <re.Match object; span=(0, 1), match='a'>
print(re.match(r'(?:a+)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>
print(re.match(r'(?:a+)*', "a"))
#=> <re.Match object; span=(0, 1), match='a'>
print(re.match(r'(?:a+)+', "a"))
#=> <re.Match object; span=(0, 1), match='a'> |
Hi @kkos and thanks for helping me understand the issue 👍 I don’t think the nested operators are supported easily, but I will have a look and get back to you |
(1) Matching a? or a* with an empty string failed.
(2) Using nested repeat operators failed. For example, a?+ with string "a".
The text was updated successfully, but these errors were encountered: