""" get_date.py extract a date from a string using regular expressions $ python get_date.py result is [2020, 9, 29] google "python re" for all the details ... Jim M in class | Sep 14 """ import re # an example string url = "https://foo.com/some/stuff/2020/09/29/more" # Here's a regular expression that we can use to "capture" # the year, month, and day , made up of 4 digits / 2 digits / 2 digits # # (\d{4})/(\d{2})/(\d{2}) # \d means integer digit regex = r'(\d{4})/(\d{2})/(\d{2})' # r'' is "raw string" in pythong match = re.search(regex, url) if match: # if the regex was matched ... results = list(map(int, match.groups())) print("result is ", results)