File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ def print_groups(match):
29
29
m = p .match ("dog" , 2 )
30
30
print_groups (m )
31
31
32
- m = p .match ("dog" , 3 ) # Past end of input
32
+ # No match past end of input
33
+ m = p .match ("dog" , 5 )
33
34
print_groups (m )
34
35
35
36
m = p .match ("dog" , 0 , 1 )
@@ -40,11 +41,22 @@ def print_groups(match):
40
41
m = p .match ("dog" , 1 )
41
42
print_groups (m )
42
43
43
- # End at begging means searching empty string
44
+ # End at beginning means searching empty string
44
45
p = re .compile (r"o" )
45
46
m = p .match ("dog" , 1 , 1 )
46
47
print_groups (m )
47
48
49
+ # End before the beginning doesn't match anything
50
+ m = p .match ("dog" , 2 , 1 )
51
+ print_groups (m )
52
+
53
+ # Negative starting values don't crash
54
+ m = p .search ("dog" , - 2 )
55
+ print_groups (m )
56
+
57
+ m = p .search ("dog" , - 2 , - 5 )
58
+ print_groups (m )
59
+
48
60
# Search also works
49
61
print ("--search" )
50
62
@@ -57,3 +69,10 @@ def print_groups(match):
57
69
58
70
m = p .search ("dog" , 2 )
59
71
print_groups (m )
72
+
73
+ # Negative starting values don't crash
74
+ m = p .search ("dog" , - 2 )
75
+ print_groups (m )
76
+
77
+ m = p .search ("dog" , - 2 , - 5 )
78
+ print_groups (m )
You can’t perform that action at this time.
0 commit comments