Skip to content

Commit 16e09bb

Browse files
committed
Removed unneeded escapes in regular expressions
1 parent e769830 commit 16e09bb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cmd2/parsing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class MacroArg:
3434
# Pattern used to find normal argument
3535
# Digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side
3636
# Match strings like: {5}, {{{{{4}, {2}}}}}
37-
macro_normal_arg_pattern = re.compile(r'(?<!\{)\{\d+\}|\{\d+\}(?!\})')
37+
macro_normal_arg_pattern = re.compile(r'(?<!{){\d+}|{\d+}(?!})')
3838

3939
# Pattern used to find escaped arguments
4040
# Digits surrounded by 2 or more braces on both sides
4141
# Match strings like: {{5}}, {{{{{4}}, {{2}}}}}
42-
macro_escaped_arg_pattern = re.compile(r'\{{2}\d+\}{2}')
42+
macro_escaped_arg_pattern = re.compile(r'{{2}\d+}{2}')
4343

4444
# Finds a string of digits
4545
digit_pattern = re.compile(r'\d+')

cmd2/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def natural_keys(input_str: str) -> List[Union[int, str]]:
229229
:param input_str: string to convert
230230
:return: list of strings and integers
231231
"""
232-
return [try_int_or_force_to_lower_case(substr) for substr in re.split('(\d+)', input_str)]
232+
return [try_int_or_force_to_lower_case(substr) for substr in re.split(r'(\d+)', input_str)]
233233

234234

235235
def natural_sort(list_to_sort: Iterable[str]) -> List[str]:

0 commit comments

Comments
 (0)