Skip to content

Commit e698d9e

Browse files
committed
Update all comments in regex lesson
1 parent a05baf3 commit e698d9e

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

ultimatepython/advanced/regex.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@
88

99

1010
def main():
11-
# Running `search` with "Hello" returns a `Match` object for first Hello
11+
# Running `search` with "Hello" has a match for first Hello
1212
assert re.search(r"Hello", _TEXT_HELLO).start() == 6
1313

14-
# Running `search` with "Hello$" returns a `Match` object for last Hello
14+
# Running `search` with "Hello$" has a match for last Hello
1515
assert re.search(r"Hello$", _TEXT_HELLO).start() == 12
1616

17-
# Running `findall` with "Hi \w+" returns a list of strings
17+
# Running `search` with "(Hello) (Hello)" has matches for Hello
18+
assert re.search(r"(Hello) (Hello)", _TEXT_HELLO).groups() == ("Hello", "Hello")
19+
20+
# Running `findall` with "Hi \w+" has list of strings
1821
assert re.findall(r"\w+", _TEXT_NAMES) == ["John", "Jane"]
1922

20-
# Running `match` with "[123]+" returns a `None` object
23+
# Running `match` with "[123]+" has nothing
2124
assert re.match(r"[123]+", _TEXT_ABC123) is None
2225

23-
# Running `match` with "[abc]+" returns a `Match` object
26+
# Running `match` with "[abc]+" has a match for abc
2427
assert re.match(r"[abc]+", _TEXT_ABC123).group(0) == "abc"
2528

26-
# Running `fullmatch` with "[\w]+" returns a `None` object
29+
# Running `fullmatch` with "[\w]+" has nothing
2730
assert re.fullmatch(r"[\w]+", _TEXT_BYE) is None
2831

29-
# Running `fullmatch` with "[\w ]+" returns a `Match` object
32+
# Running `fullmatch` with "[\w ]+" has a full match
3033
assert re.fullmatch(r"[\w ]+", _TEXT_BYE).group(0) == _TEXT_BYE
3134

3235
# There are many more ways to leverage regular expressions than what

0 commit comments

Comments
 (0)