Regular Expressions 101

Library entries

Date - Extract & Validate - Fully tested - Format YYYY-MM-DD (dynamic parts separator / can use a different separator)

Vote

2

Regular Expression
javascript

/
(?<=\D|^)(?<year>\d{4})(?<sep>[^\w\s])(?<month>1[0-2]|0[1-9])\k<sep>(?<day>0[1-9]|[12][0-9]|(?<=11\k<sep>|[^1][4-9]\k<sep>)30|(?<=1[02]\k<sep>|[^1][13578]\k<sep>)3[01])(?=\D|$)
/
gm

Description

Loading markdown...
Submitted by Elie Grenon (DrunkenPoney) <elie.grenon.1@gmail.com> - a year ago