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>
This commit is contained in:
parent
c0a25a69eb
commit
1ea06b99d8
@ -31,6 +31,6 @@ m = re.match(r"(([0-9]*)([a-z]*)\d*)", "1234hello567")
|
|||||||
print_groups(m)
|
print_groups(m)
|
||||||
|
|
||||||
# named class within a class set
|
# named class within a class set
|
||||||
print_groups(re.match("([^\s]+)\s*([^\s]+)", "1 23"))
|
print_groups(re.match(r"([^\s]+)\s*([^\s]+)", "1 23"))
|
||||||
print_groups(re.match("([\s\d]+)([\W]+)", "1 2-+="))
|
print_groups(re.match(r"([\s\d]+)([\W]+)", "1 2-+="))
|
||||||
print_groups(re.match("([\W]+)([^\W]+)([^\S]+)([^\D]+)", " a_1 23"))
|
print_groups(re.match(r"([\W]+)([^\W]+)([^\S]+)([^\D]+)", " a_1 23"))
|
||||||
|
|||||||
@ -15,9 +15,9 @@ def multiply(m):
|
|||||||
return str(int(m.group(0)) * 2)
|
return str(int(m.group(0)) * 2)
|
||||||
|
|
||||||
|
|
||||||
print(re.sub("\d+", multiply, "10 20 30 40 50"))
|
print(re.sub(r"\d+", multiply, "10 20 30 40 50"))
|
||||||
|
|
||||||
print(re.sub("\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
|
print(re.sub(r"\d+", lambda m: str(int(m.group(0)) // 2), "10 20 30 40 50"))
|
||||||
|
|
||||||
|
|
||||||
def A():
|
def A():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user