Python Tip #319 (of 365): Name your regular expression capture groups. Capture g...

@treyhunner@mastodon.social

Python Tip #319 (of 365):

Name your regular expression capture groups.

Capture groups are neat, but it can be confusing figuring out what the group numbers represent:

>>> match = re‍.search(r"(\d{2})/(\d{2})/(\d{4})", "from 12/22/1629")
>>> match[3]
'1629'

🧡 (1/3)

#Python #DailyPythonTip