summaryrefslogtreecommitdiff
path: root/cmd2/parsing.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-27 11:38:53 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-27 11:38:53 -0400
commit98a763c2e4d75bfb2d59738826f992d56a0d03c7 (patch)
tree0610d46f9256a4a3b9725a9d6ada1ea907cc6f5b /cmd2/parsing.py
parent1148a1227d98e7b461783a009013ba3829eb8f9b (diff)
downloadcmd2-git-98a763c2e4d75bfb2d59738826f992d56a0d03c7.tar.gz
Added unit tests for MacroArg regular expressions
Diffstat (limited to 'cmd2/parsing.py')
-rw-r--r--cmd2/parsing.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index 696904ff..e1d7b76b 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -30,11 +30,13 @@ class MacroArg:
is_escaped = attr.ib(validator=attr.validators.instance_of(bool), type=bool)
# Pattern used to find normal argument
+ # Digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side
# Match strings like: {5}, {{{{{4}, {2}}}}}
macro_normal_arg_pattern = re.compile(r'(?<!\{)\{\d+\}|\{\d+\}(?!\})')
- # Pattern used to find escaped arguments (2 or more braces on each side of digit)
- # Match strings like: {{5}}, {{{{{4}}, {{2}}}}}, {{{4}}}
+ # Pattern used to find escaped arguments
+ # Digits surrounded by 2 or more braces on both sides
+ # Match strings like: {{5}}, {{{{{4}}, {{2}}}}}
macro_escaped_arg_pattern = re.compile(r'\{{2}\d+\}{2}')
# Finds a string of digits