Skip to content

Commit

Permalink
Replace regex sub with simple string replace (#1095)
Browse files Browse the repository at this point in the history
* Replace regex sub with simple string replace

* Remove regex version pin
  • Loading branch information
DJRHails committed Nov 14, 2022
1 parent 7636266 commit 0f5d9c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
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

0 comments on commit 0f5d9c5

Please sign in to comment.