-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python: Regexp: Handle repetions {n} (with no ,) #3500
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
Conversation
As Taus mentioned, we might consider checking if there is a dual problem with caret and if solving that should then be part of this PR. |
As ar as I can tell, all these are improvements
@@ -207,9 +207,9 @@ | |||
| ax{3,} | sequence | 0 | 6 | | |||
| ax{3} | char | 0 | 1 | | |||
| ax{3} | char | 1 | 2 | | |||
| ax{3} | char | 2 | 3 | | |||
| ax{3} | char | 3 | 4 | | |||
| ax{3} | char | 4 | 5 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why 4-5 is in there, but both that and removing 2-3 is consistent with how {n,m}
is handled..
I was perusing the Python >>> re.match("(\Aab$|\Aba$)$\Z", "ab")
<_sre.SRE_Match object; span=(0, 2), match='ab'> works as expected. I don't know that we're explicitly handling these cases here, so perhaps a few more tests would be in order? 🙂 |
Looks like |
Made the test @tausbn sugested pass, the code feels a bit ad-hock, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides autoformatting and a maybe adding a test-case, it all looks good to me 👍
I added https://github.com/github/codeql-python-team/issues/114 to track the fact that, as @tausbn observed, we probably have the dual problem with carets. |
to make CodeScan happy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM 🚀
To solve FP report #2403 with internal issue https://github.com/github/codeql-python-team/issues/85.
The code currently only handles the syntax
{n,m}
. This adds support for{n}
.