summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/ure_split.py
blob: 0154f3abc29cc631422dab128d2d5f46cb84cc7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
try:
    import ure as re
except ImportError:
    import re

r = re.compile(" ")
s = r.split("a b c foobar")
print(s)

r = re.compile(" +")
s = r.split("a b    c   foobar")
print(s)

r = re.compile(" +")
s = r.split("a b    c   foobar", 1)
print(s)

r = re.compile(" +")
s = r.split("a b    c   foobar", 2)
print(s)

r = re.compile(" *")
s = r.split("a b    c   foobar")
# TODO - no idea how this is supposed to work, per docs, empty match == stop
# splitting, so CPython code apparently does some dirty magic.
#print(s)

r = re.compile("x*")
s = r.split("foo")
print(s)

r = re.compile("[a-f]+")
s = r.split("0a3b9")
# TODO - char classes are not yet supported by re1.5
#print(s)