fork download
  1. import re
  2. strings = [
  3. r"C:\Photos\Selfies\1|",
  4. r"C:\HDPhotos\Landscapes\2|",
  5. r"C:\Filters\Pics\12345678|",
  6. r"C:\Filters\Pics2\00000000|",
  7. r"C:\Filters\Pics2\00000000|XAV7"
  8. ]
  9.  
  10. for string in strings:
  11. matchptrn = re.match(r"(?!.*\\\d{8}\|$)(?P<file_path>.*)\|(?P<suffix>.*)", string)
  12. if matchptrn:
  13. print("FILE PATH = {}, SUFFIX = {}".format(*matchptrn.groups()))
  14.  
Success #stdin #stdout 0.03s 9628KB
stdin
Standard input is empty
stdout
FILE PATH = C:\Photos\Selfies\1, SUFFIX = 
FILE PATH = C:\HDPhotos\Landscapes\2, SUFFIX = 
FILE PATH = C:\Filters\Pics2\00000000, SUFFIX = XAV7