py4e
py4e copied to clipboard
PY4E - Regular Expressions (Chapter 11 Part 2) video
Hello, team!
I am confused here at 5:56-6:11
https://youtu.be/fiar4QZZ7Xo?t=356
Dr. Chuck says here that a non-greedy regex would produce d@u
But how would you do a non-greedy regex here?
>>> str = "from [email protected] Sat Jan 5 09"
>>> nongreedy = re.findall('\S+?@\S+?', str)
>>> greedy = re.findall('\S+@\S+', str)
>>> greedy
['[email protected]']
>>> nongreedy
['example@s']
What I expected to be non-greedy still takes a whole example part.
P.S. Thanks a lot for a very interesting and insightful course! I am going through after almost completing 2 books on Python and remember / find something beautiful or very useful even in earlier parts. Also, Dr. Chuck's videos are super easy to follow and understand.