fork download
  1. import re
  2.  
  3. regex = r"\w+,\s*f\s*\.\s*\d\s*\d\s*-\s*\d\s*\d\s*-\s*\d\s*\d\s*\d\s*\d"
  4.  
  5. test_str = ("Smith, John,\n\n"
  6. "f. 25-12-1990\n\n"
  7. "or only first part of below:\n\n"
  8. "Smith, John, f. 25-12-\n\n"
  9. "1990\n\n"
  10. "Smith, John, f. 25-\n\n"
  11. "12-1990")
  12.  
  13. matches = re.findall(regex, test_str)
  14. print(matches)
Success #stdin #stdout 0.02s 9452KB
stdin
Standard input is empty
stdout
['John,\n\nf. 25-12-1990', 'John, f. 25-12-\n\n1990', 'John, f. 25-\n\n12-1990']