Regular Expressions 101

Community Library

Community Library Entry

1

Regular ExpressionOpen Workspace

"
((?:\d{1,2}-)?\d{1,2})(?:st|nd|rd|th)?[ ./-](feb|\d{1,2})(?:[ ./-](\d{2,4}))?|(feb|\d{1,2})[ ./-]((?:\d{1,2}-)?\d{1,2})(?:st|nd|rd|th)?(?:[ ./-](\d{2,4}))?
"
igm

Description
Created·2022-04-07 20:19
Type·Match
Flavor·Java

A proof of concept regex that captures dates and date ranges with a variety of separators.

Works with both DMY and MDY, and if one is not needed, it can be easily deleted from the regex.

The full variety of months needs to be implemented by the programmer themselves since developing it in regex101 is unfeasible and would clutter the regex.

Submitted by Matey Krastev
Open Workspace