You are on page 1of 1

import re

def extract_date(text):
date_regex = r"[0-9]{1,2}[-,/](JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|
Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|jan|feb|mar|apr|may|jun|jul|aug|
sep|oct|nov|dec){1,2}[-,/][0-9]{2,4}" # Define the regular expression for matching
the date
match = re.search(date_regex, text) # Search for the date in the text
if match:
date = match.group()
return date
else:
return "No date found"

text = "<text>" # pass the text variable here


date = extract_date(text)
print(date)

You might also like