#100DaysOfCode in Python Transcripts
Chapter: Days 28-30: Regular Expressions
Lecture: Second day: write your own regexes

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Welcome back to 100 days of Python. This is the second day of the 3 day regEx blog. And today I want to give you some pointers
0:09 to get more familiar with regxxes and start to write your own. So we did an article, 10 Tips to Get More Out of Your RegExes.
0:19 I recommend you read through it. One thing I didn't touch on is greediness, which is important and can prevent nasty bugs.
0:28 And if you're still more a beginner in regex land, there's a nice talk at the end by Al Sweigart. Who by the way wrote an awesome Python beginner book,
0:40 called How to Automate the Boring Stuff, and it's called Yes, It's Time to Learn Regular Expressions. And that gives you a very nice overview
0:47 of regular expressions. Secondly, there's a nice how-to on the Python documentation page. Very refreshing how-to.
0:55 I read this when I wrote the 10 Tips post, it's pretty dense, but it is a very good primer into regular expression,
1:02 and what all the specific syntaxes mean, etc. If that's too much reading, which I can totally get, there's a nice online RegEx tester.
1:14 And you just select Python, and you can write here your regular expression, and test it in real time.
1:21 For example, I have some HTML with two paragraphs. And let's experiment a little bit with that greediness I mentioned. So let's match all of it.
1:32 So that's greediness because it takes everything from the starting paragraph tag to the ending one. If I do a question mark, the match becomes shorter.
1:42 It only takes the first paragraph. And you see all this nice feedback and explanations here. So that's a really great tool to experiment
1:51 writing regular expressions in Python, because you get instant feedback. So that will be the third resource I have for you today.
2:00 Just spend 20 or 30 minutes experimenting with regexes, and you'll see that they become a lot easier. Good luck.


Talk Python's Mastodon Michael Kennedy's Mastodon