Isolate date with Regex

#1
I’m trying to identify the required regex to isolate a date from a text string. The string is in the following format: January 12, 2020

I need to be able to identify any date of any year.

Can anyone help me with this?

Thanks in advance
 
#2
There is a Regex expression which can isolate the US date. But there is a small difference, your date has comma. You can edit the expression to your needs.

Code:
(?:(?:(?:(?:0?[13578]|1[02])(?<first>\/|-|\.)31)\k<first>|(?:(?:0?[13-9]|1[0-2])(?<second>\/|-|\.)(?:29|30)\k<second>))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(?<third>\/|-|\.)29\k<third>(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(?<fourth>\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\k<fourth>(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:(?:(?:January|March|May|July|August|October|December)(?<fifth>\/|-|\s)31)\k<fifth>|(?:(?:January|March|April|May|June|July|August|September|October|November|December)(?<sixth>\/|-|\s)(?:29|30)\k<sixth>))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:February(?<seventh>\/|-|\s)29\k<seventh>(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:January|February|March|April|May|June|July|August|September|October|November|December)(?<eighth>\/|-|\s)(?:0?[1-9]|1\d|2[0-8])\k<eighth>(?:(?:1[6-9]|[2-9]\d)?\d{2}))
 
#3
Hi,

Assuming the date is always in that format, i.e.

Month name > space > 1 or 2 numbers for Day > comma > space > 4 digit year

....This regex should work:

(January|February|March|April|May|June|July|August|September|October|November|December) [0-9]{1,2}, [0-9]{4}

Rich
 
Top