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

Replace regex sub with simple string replace #1095

Merged
merged 2 commits into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions dateparser/languages/locale.py
Expand Up @@ -10,7 +10,6 @@

from .dictionary import Dictionary, NormalizedDictionary, ALWAYS_KEEP_TOKENS

DIGIT_GROUP_PATTERN = re.compile(r'\\d\+')
NUMERAL_PATTERN = re.compile(r'(\d+)', re.U)


Expand Down Expand Up @@ -170,7 +169,7 @@ def _generate_relative_translations(self, normalize=False):
if normalize:
value = list(map(normalize_unicode, value))
pattern = '|'.join(sorted(value, key=len, reverse=True))
pattern = DIGIT_GROUP_PATTERN.sub(r'?P<n>\d+', pattern)
pattern = pattern.replace(r'(\d+', r'(?P<n>\d+')
pattern = re.compile(r'^(?:{})$'.format(pattern), re.UNICODE | re.IGNORECASE)
relative_dictionary[pattern] = key
return relative_dictionary
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -27,7 +27,7 @@
'python-dateutil',
'pytz',
# https://bitbucket.org/mrabarnett/mrab-regex/issues/314/import-error-no-module-named
'regex !=2019.02.19,!=2021.8.27,<2022.3.15',
'regex !=2019.02.19,!=2021.8.27',
'tzlocal',
],
entry_points={
Expand Down