summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-03-04 13:51:32 +0000
committerDamien George <damien.p.george@gmail.com>2015-03-04 13:51:32 +0000
commit6cb6947b99e57ababc70fcc0fccd59038682c885 (patch)
treeaded483c33512e2a805f91e2f78a9c7f43391acd /tests
parent2a68c2c21b2bb47016a4794b6fd7fcd7a02d0526 (diff)
downloadmicropython-6cb6947b99e57ababc70fcc0fccd59038682c885.tar.gz
micropython-6cb6947b99e57ababc70fcc0fccd59038682c885.zip
extmod/ure: Correctly return None when a group has no match.
See issue #1122.
Diffstat (limited to 'tests')
-rw-r--r--tests/extmod/ure_group.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/extmod/ure_group.py b/tests/extmod/ure_group.py
index e402ce5759..8078a0a855 100644
--- a/tests/extmod/ure_group.py
+++ b/tests/extmod/ure_group.py
@@ -10,7 +10,7 @@ def print_groups(match):
try:
i = 0
while True:
- print(m.group(i))
+ print(match.group(i))
i += 1
except IndexError:
pass
@@ -20,3 +20,9 @@ print_groups(m)
m = re.match(r'([0-9]*)(([a-z]*)([0-9]*))','1234hello567')
print_groups(m)
+
+# optional group that matches
+print_groups(re.match(r'(a)?b(c)', 'abc'))
+
+# optional group that doesn't match
+print_groups(re.match(r'(a)?b(c)', 'bc'))