fork download
  1. import re
  2.  
  3. regex = r"\bDOB ((?:(?:3[01]|[12][0-9]|0?[1-9]) [A-Za-z]+ )?\d{4})\b"
  4. test_str = ("DOB 23 Jun 1959; alt. DOB 23 Jun 1958\n"
  5. "DOB 1959; alt. DOB 1958")
  6.  
  7. print(re.findall(regex, test_str))
Success #stdin #stdout 0.02s 9556KB
stdin
Standard input is empty
stdout
['23 Jun 1959', '23 Jun 1958', '1959', '1958']