Skip to content

Commit ca5edfd

Browse files
committed
added one case
1 parent 386e6c8 commit ca5edfd

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

python 2/koans/about_regex.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def test_matching_literal_text_how_many(self):
3434
m = re.match('Felix', string) #TIP: Maybe match it's not the best option
3535
self.assertEqual(len(m),2, "I want to know how many times appears my name")
3636

37-
3837
def test_matching_any_character(self):
3938
"""
4039
Lesson 1 Matching any character
@@ -49,9 +48,8 @@ def test_matching_any_character(self):
4948
+ "sa1.xls"
5049

5150
#TIP: remember the issue of this lesson
52-
self.assertEquals(len(re.findall("a", string)),3, "I want to find all files for North America(na) or South America(sa)")
51+
self.assertEquals(len(re.findall(__, string)),3, "I want to find all files for North America(na) or South America(sa)")
5352

54-
5553
def test_matching_special_character(self):
5654
"""
5755
Lesson 1 Matching special character
@@ -69,3 +67,22 @@ def test_matching_special_character(self):
6967
#TIP you can use the pattern .a. which matches in above test but in this case matches more than you want
7068
self.assertEquals(len(re.findall(".a.", string)),3, "I want to find all files for North America(na) or South America(sa)")
7169

70+
def test_matching_set_character(self):
71+
"""
72+
Lesson 1 Matching sets of characters
73+
74+
A set of characters is defined using the metacharacters [ and ]. Everything between them is part of the set and
75+
any one of the set members must match (but not all).
76+
"""
77+
string = "sales.xlx\n" \
78+
+ "sales1.xls\n" \
79+
+ "orders3.xls\n" \
80+
+ "apac1.xls\n" \
81+
+ "sales2.xls\n" \
82+
+ "na1.xls\n" \
83+
+ "na2.xls\n" \
84+
+ "sa1.xls\n" \
85+
+ "ca1.xls"
86+
#TIP you can use the pattern .a. which matches in above test but in this case matches more than you want
87+
self.assertEquals(len(re.findall(".a.", string)),3, "I want to find all files for North America(na) or South America(sa), but not (ca)")
88+

0 commit comments

Comments
 (0)