fork download
  1. import re
  2. regex = r"^([a-zA-Z]:)\\(?:.*\\)?(\d{2}-\d{2}-\d{4}[a-zA-Z]?)"
  3. text = r"Q:\Region01s\FY 02\02-01-1716A.pdf"
  4. match = re.search(regex, text)
  5. if match:
  6. print(f"{match.group(1)} {match.group(2)}")
Success #stdin #stdout 0.04s 9616KB
stdin
Standard input is empty
stdout
Q: 02-01-1716A