{\bfseries{Contributing}}

\begin{quote}
Generate a regex from a string or array of strings. \end{quote}
Please consider following this project\textquotesingle{}s author, \href{https://github.com/jonschlinkert}{\texttt{ Jon Schlinkert}}, and consider starring the project to show your \+:heart\+: and support.


\begin{DoxyItemize}
\item \href{\#install}{\texttt{ Install}}
\item \href{\#usage}{\texttt{ Usage}}
\item \href{\#options}{\texttt{ Options}}
\begin{DoxyItemize}
\item \href{\#optionscontains}{\texttt{ options.\+contains}}
\item \href{\#optionsnegate}{\texttt{ options.\+negate}}
\item \href{\#optionsnocase}{\texttt{ options.\+nocase}}
\item \href{\#optionsflags}{\texttt{ options.\+flags}}
\item \href{\#optionscache}{\texttt{ options.\+cache}}
\item \href{\#optionssafe}{\texttt{ options.\+safe}}
\end{DoxyItemize}
\item \href{\#about}{\texttt{ About}}
\begin{DoxyItemize}
\item \href{\#related-projects}{\texttt{ Related projects}}
\item \href{\#author}{\texttt{ Author}}
\item \href{\#license}{\texttt{ License}}
\end{DoxyItemize}
\end{DoxyItemize}

\+\_\+(TOC generated by \href{https://github.com/verbose/verb}{\texttt{ verb}} using \href{https://github.com/jonschlinkert/markdown-toc}{\texttt{ markdown-\/toc}})\+\_\+\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30512}{}\doxysection{Install}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30512}
Install with \href{https://www.npmjs.com/}{\texttt{ npm}}\+:


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

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30513}{}\doxysection{Usage}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30513}

\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegex = require('to-\/regex');}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegex('foo'));}
\DoxyCodeLine{//=> /\string^(?:foo)\$/}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegex('foo', \{negate: true\}));}
\DoxyCodeLine{//=> /\string^(?:(?:(?!\string^(?:foo)\$).)*)\$/}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegex('foo', \{contains: true\}));}
\DoxyCodeLine{//=> /(?:foo)/}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegex(['foo', 'bar'], \{negate: true\}));}
\DoxyCodeLine{//=> /\string^(?:(?:(?!\string^(?:(?:foo)|(?:bar))\$).)*)\$/}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(toRegex(['foo', 'bar'], \{negate: true, contains: true\}));}
\DoxyCodeLine{//=> /\string^(?:(?:(?!(?:(?:foo)|(?:bar))).)*)\$/ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30514}{}\doxysection{Options}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30514}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30515}{}\doxysubsection{options.\+contains}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30515}
{\bfseries{Type}}\+: {\ttfamily Boolean}

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

Generate a regex that will match any string that {\itshape contains} the given pattern. By default, regex is strict will only return true for exact matches.


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegex = require('to-\/regex');}
\DoxyCodeLine{console.log(toRegex('foo', \{contains: true\}));}
\DoxyCodeLine{//=> /(?:foo)/ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30516}{}\doxysubsection{options.\+negate}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30516}
{\bfseries{Type}}\+: {\ttfamily Boolean}

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

Create a regex that will match everything except the given pattern.


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegex = require('to-\/regex');}
\DoxyCodeLine{console.log(toRegex('foo', \{negate: true\}));}
\DoxyCodeLine{//=> /\string^(?:(?:(?!\string^(?:foo)\$).)*)\$/ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30517}{}\doxysubsection{options.\+nocase}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30517}
{\bfseries{Type}}\+: {\ttfamily Boolean}

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

Adds the {\ttfamily i} flag, to enable case-\/insensitive matching.


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegex = require('to-\/regex');}
\DoxyCodeLine{console.log(toRegex('foo', \{nocase: true\}));}
\DoxyCodeLine{//=> /\string^(?:foo)\$/i }

\end{DoxyCode}


Alternatively you can pass the flags you want directly on \href{\#options.flags}{\texttt{ options.\+flags}}.\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30518}{}\doxysubsection{options.\+flags}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30518}
{\bfseries{Type}}\+: {\ttfamily String}

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

Define the flags you want to use on the generated regex.


\begin{DoxyCode}{0}
\DoxyCodeLine{var toRegex = require('to-\/regex');}
\DoxyCodeLine{console.log(toRegex('foo', \{flags: 'gm'\}));}
\DoxyCodeLine{//=> /\string^(?:foo)\$/gm}
\DoxyCodeLine{console.log(toRegex('foo', \{flags: 'gmi', nocase: true\})); //<= handles redundancy}
\DoxyCodeLine{//=> /\string^(?:foo)\$/gmi }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30519}{}\doxysubsection{options.\+cache}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30519}
{\bfseries{Type}}\+: {\ttfamily Boolean}

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

Generated regex is cached based on the provided string and options. As a result, runtime compilation only happens once per pattern (as long as options are also the same), which can result in dramatic speed improvements.

This also helps with debugging, since adding options and pattern are added to the generated regex.

{\bfseries{Disable caching}}


\begin{DoxyCode}{0}
\DoxyCodeLine{toRegex('foo', \{cache: false\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30520}{}\doxysubsection{options.\+safe}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30520}
{\bfseries{Type}}\+: {\ttfamily Boolean}

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

Check the generated regular expression with \href{https://github.com/substack/safe-regex}{\texttt{ safe-\/regex}} and throw an error if the regex is potentially unsafe.

{\bfseries{Examples}}


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(toRegex('(x+x+)+y'));}
\DoxyCodeLine{//=> /\string^(?:(x+x+)+y)\$/}
\DoxyCodeLine{}
\DoxyCodeLine{// The following would throw an error}
\DoxyCodeLine{toRegex('(x+x+)+y', \{safe: true\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30521}{}\doxysection{About}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30521}
$<$details$>$

Pull requests and stars are always welcome. For bugs and feature requests, \href{../../issues/new}{\texttt{ please create an issue}}.

$<$/details$>$

$<$details$>$

{\bfseries{Running Tests}} 

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}


$<$/details$>$

$<$details$>$

{\bfseries{Building docs}} 

\+\_\+(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}


$<$/details$>$\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30522}{}\doxysubsection{Related projects}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30522}
You might also be interested in these projects\+:


\begin{DoxyItemize}
\item \href{https://www.npmjs.com/package/has-glob}{\texttt{ has-\/glob}}\+: Returns {\ttfamily true} if an array has a glob pattern. $\vert$ \href{https://github.com/jonschlinkert/has-glob}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/is-glob}{\texttt{ is-\/glob}}\+: Returns {\ttfamily true} if the given string looks like a glob pattern or an extglob pattern… \href{https://github.com/jonschlinkert/is-glob}{\texttt{ more}} $\vert$ \href{https://github.com/jonschlinkert/is-glob}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/path-regex}{\texttt{ path-\/regex}}\+: Regular expression for matching the parts of a file path. $\vert$ \href{https://github.com/regexps/path-regex}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/to-regex-range}{\texttt{ to-\/regex-\/range}}\+: Pass two numbers, get a regex-\/compatible source string for matching ranges. Validated against more than… \href{https://github.com/micromatch/to-regex-range}{\texttt{ more}} $\vert$ \href{https://github.com/micromatch/to-regex-range}{\texttt{ homepage}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_to_regex_README_autotoc_md30523}{}\doxysubsection{Author}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30523}
{\bfseries{Jon Schlinkert}}


\begin{DoxyItemize}
\item \href{https://linkedin.com/in/jonschlinkert}{\texttt{ linkedin/in/jonschlinkert}}
\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_to_regex_README_autotoc_md30524}{}\doxysubsection{License}\label{md_sfcode_node_modules_to_regex_README_autotoc_md30524}
Copyright © 2018, \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 February 24, 2018.} 