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

Treatment of regexes #23

Open
robertodr opened this issue Jan 22, 2019 · 1 comment
Open

Treatment of regexes #23

robertodr opened this issue Jan 22, 2019 · 1 comment

Comments

@robertodr
Copy link
Contributor

Defining a filter based on regexes, i.e. using re/from_re/to_re, assumes a string
is passed in. runtest then uses re.compile on the string to create the regex object.
I think this should be extended to allow passing a regex object (that is, the result of re.compile)
directly.
As as example, to match "Foo" case-insensitive the following currently works:

regex = r'(?i)Foo'
get_filter(re=regex, ...)

see: https://docs.python.org/3/library/re.html#regular-expression-syntax
The following does not, but I think it should:

regex = re.compile('Foo', re.I)
get_filter(re=regex, ...)

especially because passing flags modifying regexes looks less obscure.

@bast
Copy link
Owner

bast commented Jan 22, 2019

Very good suggestion - I will try to implement this without breaking the API.

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

2 participants