Skip to content

Commit 1ea06b9

Browse files
committed
tests/extmod: Fix regex strings to be of r"" type.
Otherwise escape characters like \s and \W won't work correctly. Signed-off-by: Damien George <damien@micropython.org>
1 parent c0a25a6 commit 1ea06b9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

tests/extmod/re_namedclass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def print_groups(match):
3131
print_groups(m)
3232

3333
# named class within a class set
34-
print_groups(re.match("([^\s]+)\s*([^\s]+)", "1 23"))
35-
print_groups(re.match("([\s\d]+)([\W]+)", "1 2-+="))
36-
print_groups(re.match("([\W]+)([^\W]+)([^\S]+)([^\D]+)", " a_1 23"))
34+
print_groups(re.match(r"([^\s]+)\s*([^\s]+)", "1 23"))
35+
print_groups(re.match(r"([\s\d]+)([\W]+)", "1 2-+="))
36+
print_groups(re.match(r"([\W]+)([^\W]+)([^\S]+)([^\D]+)", " a_1 23"))

tests/extmod/re_sub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def multiply(m):
1515
return str(int(m.group(0)) * 2)
1616

1717

18-
print(re.sub("\d+", multiply, "10 20 30 40 50"))
18+
print(re.sub(r"\d+", multiply, "10 20 30 40 50"))
1919

20-
print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
20+
print(re.sub(r"\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
2121

2222

2323
def A():

0 commit comments

Comments
 (0)