detect potentially \href{http://regular-expressions.mobi/catastrophic.html}{\texttt{ catastrophic}} \href{http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html}{\texttt{ exponential-\/time}} regular expressions by limiting the \href{https://en.wikipedia.org/wiki/Star_height}{\texttt{ star height}} to 1

WARNING\+: This module merely {\itshape seems} to work given all the catastrophic regular expressions I could find scouring the internet, but I don\textquotesingle{}t have enough of a background in automata to be absolutely sure that this module will catch all exponential-\/time cases.

\href{https://ci.testling.com/substack/safe-regex}{\texttt{ }}

\href{http://travis-ci.org/substack/safe-regex}{\texttt{ }}\hypertarget{md_sfcode_node_modules_safe_regex_readme_autotoc_md26078}{}\doxysection{example}\label{md_sfcode_node_modules_safe_regex_readme_autotoc_md26078}

\begin{DoxyCode}{0}
\DoxyCodeLine{var safe = require('safe-\/regex');}
\DoxyCodeLine{var regex = process.argv.slice(2).join(' ');}
\DoxyCodeLine{console.log(safe(regex)); }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{\$ node safe.js '(x+x+)+y'}
\DoxyCodeLine{false}
\DoxyCodeLine{\$ node safe.js '(beep|boop)*'}
\DoxyCodeLine{true}
\DoxyCodeLine{\$ node safe.js '(a+)\{10\}'}
\DoxyCodeLine{false}
\DoxyCodeLine{\$ node safe.js '\(\backslash\)blocation\(\backslash\)s*:[\string^:\(\backslash\)n]+\(\backslash\)b(Oakland|San Francisco)\(\backslash\)b'}
\DoxyCodeLine{true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_safe_regex_readme_autotoc_md26079}{}\doxysection{methods}\label{md_sfcode_node_modules_safe_regex_readme_autotoc_md26079}

\begin{DoxyCode}{0}
\DoxyCodeLine{var safe = require('safe-\/regex') }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_safe_regex_readme_autotoc_md26080}{}\doxysubsection{var ok = safe(re, opts=\{\})}\label{md_sfcode_node_modules_safe_regex_readme_autotoc_md26080}
Return a boolean {\ttfamily ok} whether or not the regex {\ttfamily re} is safe and not possibly catastrophic.

{\ttfamily re} can be a {\ttfamily Reg\+Exp} object or just a string.

If the {\ttfamily re} is a string and is an invalid regex, returns {\ttfamily false}.


\begin{DoxyItemize}
\item {\ttfamily opts.\+limit} -\/ maximum number of allowed repetitions in the entire regex. Default\+: {\ttfamily 25}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_safe_regex_readme_autotoc_md26081}{}\doxysection{install}\label{md_sfcode_node_modules_safe_regex_readme_autotoc_md26081}
With \href{https://npmjs.org}{\texttt{ npm}} do\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install safe-\/regex }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_safe_regex_readme_autotoc_md26082}{}\doxysection{license}\label{md_sfcode_node_modules_safe_regex_readme_autotoc_md26082}
MIT 