Community Patterns

Community Library Entry

0

Regular Expression
Created·2018-08-14 15:11
Flavor·PCRE (Legacy)

/
(?<=^|\s)(?<Day>0[1-9]|1[0-9]|2[0-9]|3[0-1]|[1-9])(?:st|nd|rd|th)?(?:\/| |-|\.)(?<Month>0[1-9]|1[0-2]|[1-9]|Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|November|Dec|December)(?:-|\/| |\.)(?<Year>(?:[1-2]\d)?(?:\d\d))(?=\s)
/
gmi
Open regex in editor

Description

Finds any date in UK date format with or without century and allows for month names and abreviations as well as ordinal indicators (st, nd, rd, th)

This expression uses look behind and look ahead to ensure the date is either at the start of a line or preceeded by whitspace.

Submitted by anonymous