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

Python supports setting flags in the regex #1271

Closed
stdedos opened this issue Jan 17, 2020 · 3 comments
Closed

Python supports setting flags in the regex #1271

stdedos opened this issue Jan 17, 2020 · 3 comments
Labels

Comments

@stdedos
Copy link

stdedos commented Jan 17, 2020

Bug Description

If flags are given at the beginning of the regex, REPL flags should follow the flags set on the regex string itself.

Reproduction steps

(?mu)^\h*\+(.+)\+\h*$

"(?mu)^\h*\+(.+)\+\h*$"
mu
All the errors detected are listed below, from left to right, as they appear in the pattern.
(? Incomplete group structure
) Incomplete group structure

Expected Outcome

  • Pattern is recognised
  • mu flags are set, without removing them from the regex string
  • Aforementioned flags have a two-way sync with each other (?)

Browser

GChrome 79+

OS

Ubuntu 16.04.X

@stdedos stdedos added the bug label Jan 17, 2020
@Doqnach
Copy link
Collaborator

Doqnach commented Jan 17, 2020

Inline flags and global flags are two different things... I don't think your expectation of having the global flags be in sync with the inline flags is correct.

@stdedos
Copy link
Author

stdedos commented Jan 18, 2020

Inline flags and global flags are two different things... I don't think your expectation of having the global flags be in sync with the inline flags is correct.

True, but I don't expect that a user will ever have a different set of flags set.
User will either have global flags set, or inline.

Assuming I am making sense, then this would only help a user in copy-pasting between his code and his playground.

The only issue I see is if the user explicitly wants to set global flags, and, at the same time, explicitly does not want to set inline flags. However, this could be easily solvable (if user-pasted string has no inline flags, then don't attempt to create them)

@firasdib
Copy link
Owner

firasdib commented Feb 1, 2020

g isn't a valid flag in python, but its kept to keep a consistent UI and UX on the site.

If its included, the regex will be invalid when used in code. I try to refrain from that as much as possible.

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

No branches or pull requests

3 participants