#100DaysOfCode in Python Transcripts
Chapter: Days 28-30: Regular Expressions
Lecture: Comparing re.search and re.match

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now those string operations were pretty basic, but usually we need something more advanced. Meet, regex. The re module has two main methods.
0:12 search and match. match, matches from start to end. Search can match a substring. It's best to use an example. I'm using raw strings by the way,
0:26 because then I can just use special characters with a single backslash and not having to escape them which makes my regexes more readable.
0:35 So again, we have the same awesome I'm doing a 100 days of code challenge and let's... do a re.search first. So I'm going to... match a...
0:49 part of that string and you can do this as well with just I am in but the point is to just show how you would make a regular
0:58 expression and what a match object would look like. To contrast that with match, this won't work. Oops. Match takes two arguments.
1:14 So this is None because match ends end to end so I am is not the full string. So to do a proper match we would be doing, start with awesome,
1:31 end with challenge. On text and that works. And here you see the first part of a pattern which is '.' which matches any character, zero or more of them
1:48 up until challenge.


Talk Python's Mastodon Michael Kennedy's Mastodon