Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7bcce0

Browse files
committed
modure: Basic tests.
1 parent5edbade commitf7bcce0

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

‎tests/extmod/ure1.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
try:
2+
importureasre
3+
exceptImportError:
4+
importre
5+
6+
r=re.compile(".+")
7+
m=r.match("abc")
8+
print(m.group(0))
9+
try:
10+
m.group(1)
11+
exceptIndexError:
12+
print("IndexError")
13+
14+
r=re.compile("(.+)1")
15+
m=r.match("xyz781")
16+
print(m.group(0))
17+
print(m.group(1))
18+
try:
19+
m.group(2)
20+
exceptIndexError:
21+
print("IndexError")
22+
23+
24+
r=re.compile("o+")
25+
m=r.search("foobar")
26+
print(m.group(0))
27+
try:
28+
m.group(1)
29+
exceptIndexError:
30+
print("IndexError")
31+
32+
33+
m=re.match(".*","foo")
34+
print(m.group(0))
35+
36+
m=re.search("w.r","hello world")
37+
print(m.group(0))

‎tests/extmod/ure_split.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
try:
2+
importureasre
3+
exceptImportError:
4+
importre
5+
6+
r=re.compile(" ")
7+
s=r.split("a b c foobar")
8+
print(s)
9+
10+
r=re.compile(" +")
11+
s=r.split("a b c foobar")
12+
print(s)
13+
14+
r=re.compile(" +")
15+
s=r.split("a b c foobar",1)
16+
print(s)
17+
18+
r=re.compile(" +")
19+
s=r.split("a b c foobar",2)
20+
print(s)
21+
22+
r=re.compile(" *")
23+
s=r.split("a b c foobar")
24+
# TODO - no idea how this is supposed to work, per docs, empty match == stop
25+
# splitting, so CPython code apparently does some dirty magic.
26+
#print(s)
27+
28+
r=re.compile("x*")
29+
s=r.split("foo")
30+
print(s)
31+
32+
r=re.compile("[a-f]+")
33+
s=r.split("0a3b9")
34+
# TODO - char classes are not yet supported by re1.5
35+
#print(s)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp