calendar-date-regex
Regular expression for matching ISO 8601 calendar dates
'2015-01-25 0101 20150126 11112233 2015-13-13';//=> ['2015-01-25' '20150126']
Installation
Package managers
npm
npm install calendar-date-regex
bower
bower install calendar-date-regex
Duo
const calendarDateRegex = ;
Standalone
Download the script file directly.
API
calendarDateRegex(options)
options: Object
Return: RegExp
It returns a regular expression object that matches calendar dates (YYYY-MM-DD and YYYYMMDD).
;//=> ['16140526', '1614', '05', '26', undefined, undefined, undefined] ;//=> ['1614-05-26', undefined, undefined, undefined, '1614', '05', '26']
options.basic
Type: Boolean
Default: true
false
prevents the regex from matching the basic format (YYYYMMDD).
; //=> false
options.extended
Type: Boolean
Default: true
false
prevents the regex from matching the extended format (YYYY-MM-DD).
; //=> false
options.exact
Type: Boolean
Default: false
true
makes the regex matches only an exact calendar date string.
; //=> true; //=> false; //=> false
calendarDateRegex.noDay(options)
options: Object
(only supports exact
option)
Return: RegExp
It returns a regular expression object that matches calendar dates with reduced precision (YYYY-MM).
calendarDateRegex; //=> truecalendarDateRegex; //=> false
License
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.