Generates a regular expression for validating a range of years.
If you've ever tried to create a JavaScript regular expression for validating a range of years, you'll know it's not easy. This solves that problem.
Install with npm
$ npm i year-range-regex --save
var yearRange = require('year-range-regex');
yearRegex(1992, 2015);
//=> /^(199[2-9]|200[0-9]|201[0-5])$/
yearRange(0, 1999)
//=> /^([0-9]|[1-9][0-9]|[1-9][0-9]{2}|1[0-9]{3})$/
yearRange(2016)
//=> /^(2016)$/
- expand-range: Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… more
- fill-range: Fill in a range of numbers or letters, optionally passing an increment or multiplier to… more
- repeat-element: Create an array by repeating the given value n times.
- repeat-string: Repeat the given string n times. Fastest implementation for repeating a string.
- to-regex-range: Returns a regex-compatible range from two numbers, min and max. Useful for creating regular expressions… more
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on August 07, 2015.