{\bfseries{What does this do?}}

\begin{quote}
Pass two numbers, get a regex-\/compatible source string for matching ranges. Validated against more than 2.\+78 million test assertions. \end{quote}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33026}{}\doxysection{Install}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33026}
Install with \href{https://www.npmjs.com/}{\texttt{ npm}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save to-\/regex-\/range }

\end{DoxyCode}


Install with \href{https://yarnpkg.com}{\texttt{ yarn}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ yarn add to-\/regex-\/range }

\end{DoxyCode}


$<$details$>$

~\newline


This libary generates the {\ttfamily source} string to be passed to {\ttfamily new Reg\+Exp()} for matching a range of numbers.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegexRange = require('to-\/regex-\/range');}
\DoxyCodeLine{var regex = new RegExp(toRegexRange('15', '95')); }

\end{DoxyCode}


A string is returned so that you can do whatever you need with it before passing it to {\ttfamily new Reg\+Exp()} (like adding {\ttfamily $^\wedge$} or {\ttfamily \$} boundaries, defining flags, or combining it another string).

~\newline


$<$/details$>$

$<$details$>$

{\bfseries{Why use this library?}} 

~\newline
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33027}{}\doxysubsection{Convenience}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33027}
Creating regular expressions for matching numbers gets deceptively complicated pretty fast.

For example, let\textquotesingle{}s say you need a validation regex for matching part of a user-\/id, postal code, social security number, tax id, etc\+:


\begin{DoxyItemize}
\item regex for matching {\ttfamily 1} =$>$ {\ttfamily /1/} (easy enough)
\item regex for matching {\ttfamily 1} through {\ttfamily 5} =$>$ {\ttfamily /\mbox{[}1-\/5\mbox{]}/} (not bad...)
\item regex for matching {\ttfamily 1} or {\ttfamily 5} =$>$ {\ttfamily /(1$\vert$5)/} (still easy...)
\item regex for matching {\ttfamily 1} through {\ttfamily 50} =$>$ {\ttfamily /(\mbox{[}1-\/9\mbox{]}$\vert$\mbox{[}1-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$50)/} (uh-\/oh...)
\item regex for matching {\ttfamily 1} through {\ttfamily 55} =$>$ {\ttfamily /(\mbox{[}1-\/9\mbox{]}$\vert$\mbox{[}1-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$5\mbox{[}0-\/5\mbox{]})/} (no prob, I can do this...)
\item regex for matching {\ttfamily 1} through {\ttfamily 555} =$>$ {\ttfamily /(\mbox{[}1-\/9\mbox{]}$\vert$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$\mbox{[}1-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$\vert$5\mbox{[}0-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$55\mbox{[}0-\/5\mbox{]})/} (maybe not...)
\item regex for matching {\ttfamily 0001} through {\ttfamily 5555} =$>$ {\ttfamily /(0\{3\}\mbox{[}1-\/9\mbox{]}$\vert$0\{2\}\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$0\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$\vert$\mbox{[}1-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}\{3\}$\vert$5\mbox{[}0-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$\vert$55\mbox{[}0-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}$\vert$555\mbox{[}0-\/5\mbox{]})/} (okay, I get the point!)
\end{DoxyItemize}

The numbers are contrived, but they\textquotesingle{}re also really basic. In the real world you might need to generate a regex on-\/the-\/fly for validation.

{\bfseries{Learn more}}

If you\textquotesingle{}re interested in learning more about \href{http://www.regular-expressions.info/charclass.html}{\texttt{ character classes}} and other regex features, I personally have always found \href{http://www.regular-expressions.info/charclass.html}{\texttt{ regular-\/expressions.\+info}} to be pretty useful.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33028}{}\doxysubsection{Heavily tested}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33028}
As of April 27, 2017, this library runs \href{./test/test.js}{\texttt{ 2,783,483 test assertions}} against generated regex-\/ranges to provide brute-\/force verification that results are indeed correct.

Tests run in $\sim$870ms on my Mac\+Book Pro, 2.\+5 GHz Intel Core i7.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33029}{}\doxysubsection{Highly optimized}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33029}
Generated regular expressions are highly optimized\+:


\begin{DoxyItemize}
\item duplicate sequences and character classes are reduced using quantifiers
\item smart enough to use {\ttfamily ?} conditionals when number(s) or range(s) can be positive or negative
\item uses fragment caching to avoid processing the same exact string more than once
\end{DoxyItemize}

~\newline


$<$/details$>$\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33030}{}\doxysection{Usage}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33030}
Add this library to your javascript application with the following line of code


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegexRange = require('to-\/regex-\/range'); }

\end{DoxyCode}


The main export is a function that takes two integers\+: the {\ttfamily min} value and {\ttfamily max} value (formatted as strings or numbers).


\begin{DoxyCode}{0}
\DoxyCodeLine{var source = toRegexRange('15', '95');}
\DoxyCodeLine{//=> 1[5-\/9]|[2-\/8][0-\/9]|9[0-\/5]}
\DoxyCodeLine{}
\DoxyCodeLine{var re = new RegExp('\string^' + source + '\$');}
\DoxyCodeLine{console.log(re.test('14')); //=> false}
\DoxyCodeLine{console.log(re.test('50')); //=> true}
\DoxyCodeLine{console.log(re.test('94')); //=> true}
\DoxyCodeLine{console.log(re.test('96')); //=> false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33031}{}\doxysection{Options}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33031}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33032}{}\doxysubsection{options.\+capture}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33032}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Deafault}}\+: {\ttfamily undefined}

Wrap the returned value in parentheses when there is more than one regex condition. Useful when you\textquotesingle{}re dynamically generating ranges.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(toRegexRange('-\/10', '10'));}
\DoxyCodeLine{//=> -\/[1-\/9]|-\/?10|[0-\/9]}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegexRange('-\/10', '10', \{capture: true\}));}
\DoxyCodeLine{//=> (-\/[1-\/9]|-\/?10|[0-\/9]) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33033}{}\doxysubsection{options.\+shorthand}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33033}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Deafault}}\+: {\ttfamily undefined}

Use the regex shorthand for {\ttfamily \mbox{[}0-\/9\mbox{]}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(toRegexRange('0', '999999'));}
\DoxyCodeLine{//=> [0-\/9]|[1-\/9][0-\/9]\{1,5\}}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegexRange('0', '999999', \{shorthand: true\}));}
\DoxyCodeLine{//=> \(\backslash\)d|[1-\/9]\(\backslash\)d\{1,5\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33034}{}\doxysubsection{options.\+relax\+Zeros}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33034}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Default}}\+: {\ttfamily true}

This option only applies to {\bfseries{negative zero-\/padded ranges}}. By default, when a negative zero-\/padded range is defined, the number of leading zeros is relaxed using {\ttfamily -\/0$\ast$}.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(toRegexRange('-\/001', '100'));}
\DoxyCodeLine{//=> -\/0*1|0\{2\}[0-\/9]|0[1-\/9][0-\/9]|100}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegexRange('-\/001', '100', \{relaxZeros: false\}));}
\DoxyCodeLine{//=> -\/0\{2\}1|0\{2\}[0-\/9]|0[1-\/9][0-\/9]|100 }

\end{DoxyCode}


$<$details$>$

{\bfseries{Why are zeros relaxed for negative zero-\/padded ranges by default?}} 

Consider the following.


\begin{DoxyCode}{0}
\DoxyCodeLine{var regex = toRegexRange('-\/001', '100'); }

\end{DoxyCode}


{\itshape Note that {\ttfamily -\/001} and {\ttfamily 100} are both three digits long}.

In most zero-\/padding implementations, only a single leading zero is enough to indicate that zero-\/padding should be applied. Thus, the leading zeros would be \char`\"{}corrected\char`\"{} on the negative range in the example to {\ttfamily -\/01}, instead of {\ttfamily -\/001}, to make total length of each string no greater than the length of the largest number in the range (in other words, {\ttfamily -\/001} is 4 digits, but {\ttfamily 100} is only three digits).

If zeros were not relaxed by default, you might expect the resulting regex of the above pattern to match {\ttfamily -\/001} -\/ given that it\textquotesingle{}s defined that way in the arguments -\/ {\itshape but it wouldn\textquotesingle{}t}. It would, however, match {\ttfamily -\/01}. This gets even more ambiguous with large ranges, like {\ttfamily -\/01} to {\ttfamily 1000000}.

Thus, we relax zeros by default to provide a more predictable experience for users.

$<$/details$>$\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33035}{}\doxysection{Examples}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33035}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{3}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Range}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Result}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Compile time}}    }\\\cline{1-3}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Range}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Result}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Compile time}}    }\\\cline{1-3}
\endhead
`to\+Regex\+Range(\textquotesingle{}5, 5'){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}5{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+33μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}5, 6\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}5$|$6{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+53μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}29, 51\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}29$|$\mbox{[}34\mbox{]}\mbox{[}0-\/9\mbox{]}$|$5\mbox{[}01\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+699μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}31, 877\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}3\mbox{[}1-\/9\mbox{]}$|$\mbox{[}4-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$\mbox{[}1-\/7\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$|$8\mbox{[}0-\/6\mbox{]}\mbox{[}0-\/9\mbox{]}$|$87\mbox{[}0-\/7\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+711μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}111, 555\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}11\mbox{[}1-\/9\mbox{]}$|$1\mbox{[}2-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$\mbox{[}2-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$|$5\mbox{[}0-\/4\mbox{]}\mbox{[}0-\/9\mbox{]}$|$55\mbox{[}0-\/5\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+62μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}-\/10, 10\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}-\/\mbox{[}1-\/9\mbox{]}$|$-\/?10$|$\mbox{[}0-\/9\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+74μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}-\/100, -\/10\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}-\/1\mbox{[}0-\/9\mbox{]}$|$-\/\mbox{[}2-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$-\/100{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+49μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}-\/100, 100\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}-\/\mbox{[}1-\/9\mbox{]}$|$-\/?\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$-\/?100$|$\mbox{[}0-\/9\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+45μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}001, 100\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}0\{2\}\mbox{[}1-\/9\mbox{]}$|$0\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$100{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+158μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}0010, 1000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}0\{2\}1\mbox{[}0-\/9\mbox{]}$|$0\{2\}\mbox{[}2-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$0\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{2\}$|$1000{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+61μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 2\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}1$|$2{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+10μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 5\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/5\mbox{]}{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+24μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 10\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$10{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+23μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 100\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}$|$100{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+30μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 1000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{1,2\}$|$1000{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+52μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 10000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{1,3\}$|$10000{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+47μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 100000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{1,4\}$|$100000{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+44μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Even\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 1000000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{1,5\}$|$1000000{\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$ \+\_\+49μs\+\_\+ \textbackslash{}ilinebr $<$/td$>$ $<$/tr$>$ $<$tr class=\char`\"{}markdown\+Table\+Row\+Odd\char`\"{}$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}to\+Regex\+Range(\textquotesingle{}1, 10000000\textquotesingle{}){\ttfamily \textbackslash{}ilinebr $<$/td$>$ $<$td class=\char`\"{}markdown\+Table\+Body\+None\char`\"{}$>$}\mbox{[}1-\/9\mbox{]}$|$\mbox{[}1-\/9\mbox{]}\mbox{[}0-\/9\mbox{]}\{1,6\}$|$10000000\`{}   &{\itshape 63μs}   \\\cline{1-3}
\end{longtabu}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33036}{}\doxysection{Heads up!}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33036}
{\bfseries{Order of arguments}}

When the {\ttfamily min} is larger than the {\ttfamily max}, values will be flipped to create a valid range\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{toRegexRange('51', '29'); }

\end{DoxyCode}


Is effectively flipped to\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{toRegexRange('29', '51');}
\DoxyCodeLine{//=> 29|[3-\/4][0-\/9]|5[0-\/1] }

\end{DoxyCode}


{\bfseries{Steps / increments}}

This library does not support steps (increments). A pr to add support would be welcome.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33037}{}\doxysection{History}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33037}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33038}{}\doxysubsection{v2.\+0.\+0 -\/ 2017-\/04-\/21}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33038}
{\bfseries{New features}}

Adds support for zero-\/padding!\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33039}{}\doxysubsection{v1.\+0.\+0}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33039}
{\bfseries{Optimizations}}

Repeating ranges are now grouped using quantifiers. rocessing time is roughly the same, but the generated regex is much smaller, which should result in faster matching.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33040}{}\doxysection{Attribution}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33040}
Inspired by the python library \href{https://github.com/dimka665/range-regex}{\texttt{ range-\/regex}}.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33041}{}\doxysection{About}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33041}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33042}{}\doxysubsection{Related projects}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33042}

\begin{DoxyItemize}
\item \href{https://www.npmjs.com/package/expand-range}{\texttt{ expand-\/range}}\+: Fast, bash-\/like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… \href{https://github.com/jonschlinkert/expand-range}{\texttt{ more}} $\vert$ \href{https://github.com/jonschlinkert/expand-range}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/fill-range}{\texttt{ fill-\/range}}\+: Fill in a range of numbers or letters, optionally passing an increment or {\ttfamily step} to… \href{https://github.com/jonschlinkert/fill-range}{\texttt{ more}} $\vert$ \href{https://github.com/jonschlinkert/fill-range}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/micromatch}{\texttt{ micromatch}}\+: Glob matching for javascript/node.\+js. A drop-\/in replacement and faster alternative to minimatch and multimatch. $\vert$ \href{https://github.com/jonschlinkert/micromatch}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/repeat-element}{\texttt{ repeat-\/element}}\+: Create an array by repeating the given value n times. $\vert$ \href{https://github.com/jonschlinkert/repeat-element}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/repeat-string}{\texttt{ repeat-\/string}}\+: Repeat the given string n times. Fastest implementation for repeating a string. $\vert$ \href{https://github.com/jonschlinkert/repeat-string}{\texttt{ homepage}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33043}{}\doxysubsection{Contributing}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33043}
Pull requests and stars are always welcome. For bugs and feature requests, \href{../../issues/new}{\texttt{ please create an issue}}.\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33044}{}\doxysubsection{Building docs}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33044}
\+\_\+(This project\textquotesingle{}s readme.\+md is generated by \href{https://github.com/verbose/verb-generate-readme}{\texttt{ verb}}, please don\textquotesingle{}t edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)\+\_\+

To generate the readme, run the following command\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/g verbose/verb\#dev verb-\/generate-\/readme \&\& verb }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33045}{}\doxysubsection{Running tests}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33045}
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install \&\& npm test }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33046}{}\doxysubsection{Author}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33046}
{\bfseries{Jon Schlinkert}}


\begin{DoxyItemize}
\item \href{https://github.com/jonschlinkert}{\texttt{ github/jonschlinkert}}
\item \href{https://twitter.com/jonschlinkert}{\texttt{ twitter/jonschlinkert}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33047}{}\doxysubsection{License}\label{md_sfcode_node_modules_webpack_node_modules_to_regex_range_README_autotoc_md33047}
Copyright © 2017, \href{https://github.com/jonschlinkert}{\texttt{ Jon Schlinkert}}. Released under the \mbox{[}MIT License\mbox{]}(LICENSE).

\DoxyHorRuler{0}


{\itshape This file was generated by \href{https://github.com/verbose/verb-generate-readme}{\texttt{ verb-\/generate-\/readme}}, v0.\+6.\+0, on April 27, 2017.} 