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

re.compile(pattern).search matches substring too and hence picking files other than the mention subfolder #23

Open
Atif8Ted opened this issue Jan 17, 2022 · 0 comments

Comments

@Atif8Ted
Copy link

if matcher.search(key) and (modified_since is None or modified_since < last_modified):
.

>>> import re
>>> pattern = 'popularity_index/.*.csv'
>>> file = 'new_popularity_index/test.csv'
>>> m= re.compile(pattern)
>>> m.search(file)
<re.Match object; span=(4, 29), match='popularity_index/test.csv'>

match will be a better option to go

>>> file = 'popularity_index/test.csv'
>>> m.match(file)
<re.Match object; span=(0, 25), match='popularity_index/test.csv'>
>>> file_2='new_popularity_index/test.csv'
>>> m.match(file_2)
>>> 

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

1 participant