File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed
Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 1+ # test groups, and nested groups
2+
3+ try :
4+ import ure as re
5+ except :
6+ import re
7+
8+ def print_groups (match ):
9+ print ('----' )
10+ try :
11+ i = 0
12+ while True :
13+ print (m .group (i ))
14+ i += 1
15+ except IndexError :
16+ pass
17+
18+ m = re .match (r'(([0-9]*)([a-z]*)[0-9]*)' ,'1234hello567' )
19+ print_groups (m )
20+
21+ m = re .match (r'([0-9]*)(([a-z]*)([0-9]*))' ,'1234hello567' )
22+ print_groups (m )
Original file line number Diff line number Diff line change 1+ # test named char classes
2+
3+ try :
4+ import ure as re
5+ except :
6+ import re
7+
8+ def print_groups (match ):
9+ print ('----' )
10+ try :
11+ i = 0
12+ while True :
13+ print (m .group (i ))
14+ i += 1
15+ except IndexError :
16+ pass
17+
18+ m = re .match (r'\w+' ,'1234hello567 abc' )
19+ print_groups (m )
20+
21+ m = re .match (r'(\w+)\s+(\w+)' ,'ABC \t 1234hello567 abc' )
22+ print_groups (m )
23+
24+ m = re .match (r'(\S+)\s+(\D+)' ,'ABC \t hello abc567 abc' )
25+ print_groups (m )
26+
27+ m = re .match (r'(([0-9]*)([a-z]*)\d*)' ,'1234hello567' )
28+ print_groups (m )
Original file line number Diff line number Diff line change 3131
3232r = re .compile ("[a-f]+" )
3333s = r .split ("0a3b9" )
34- # TODO - char classes are not yet supported by re1.5
35- #print(s)
34+ print (s )
You can’t perform that action at this time.
0 commit comments