talkpython / 100daysofcode-with-python-course

Course materials and handouts for #100DaysOfCode in Python course
https://training.talkpython.fm/courses/explore_100days_in_python/100-days-of-code-in-python
MIT License
2.09k stars 1.07k forks source link

Issue in the #100DaysOfCode talkpython course Days 28-30 regex #12

Closed vipinreyo closed 6 years ago

vipinreyo commented 6 years ago

Hi guys In the recording for 'findall' section, Bob mentions in one of the exercises, '\w+' as one or more characters. Shouldn't that be one or more 'words'? Recording time: 1:17

Cheers

bbelderbos commented 6 years ago

You got me doubting for a sec there, but it is indeed a character class:

https://docs.python.org/3.8/library/re.html

\w For Unicode (str) patterns: Matches Unicode word characters; this includes most characters that can be part of a word in any language, as well as numbers and the underscore. If the ASCII flag is used, only [a-zA-Z0-9_] is matched.

Or letting the code speak:

import re re.match(r'\w', 'a') <_sre.SRE_Match object; span=(0, 1), match='a’>

Thanks for keeping a critical eye :)

vipinreyo commented 6 years ago

Thank for the clarification Bob.

Cheers