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

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy