Socket
Book a DemoInstallSign in
Socket

year-range-regex

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

year-range-regex

Generates a regular expression for validating a range of years.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

year-range-regex NPM version

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

Install with npm

$ npm i year-range-regex --save

Usage

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

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on August 07, 2015.

Keywords

character

FAQs

Package last updated on 07 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts