fork download
  1. import re
  2.  
  3. pattern = r"\b(\d+ (?:jan|feb|mar|ap|may|jun|jul|aug|sep|oct|nov|dec))(?=.*\b(20\d\d))\b"
  4. s = r"30 jan and 6 apr and 12 oct 2022"
  5.  
  6. res = [' '.join(s) for s in re.findall(pattern, s)]
  7. print(res)
Success #stdin #stdout 0.03s 9436KB
stdin
Standard input is empty
stdout
['30 jan 2022', '12 oct 2022']