Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mals14/129427d5fb020f7ba4af4dfeabdb3f49 to your computer and use it in GitHub Desktop.
Save mals14/129427d5fb020f7ba4af4dfeabdb3f49 to your computer and use it in GitHub Desktop.
get date YYYY-MM-DD from string regular expression.py
def get_date_s_from_string(s):
"""extract YYYY-MM-DD from string formatted YYYY-MM-DD_...
Returns:
[type] -- [description]
"""
re_pattern = '\d{4}-\d{2}-\d{2}'
return re.search(re_pattern,s)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment