regex-test
Safely test strings against any regex with a timeout.
Installation
npm:
npm install regex-test
yarn:
yarn add regex-test
GitHub:
git clone https://github.com/venomaze/regex-test.git
Usage
First create a new instance:
const RegexTest = ; const regex = timeout: 500 // ms safeRegexOnly: true;
Then you can use the test
method this way:
const pattern = /^*{1}[a-z0-9]+[.]{1}$/; regex ; regex ;
Options
The options are:
- timeout: The timeout for regular expression tests in milliseconds. (Default to 1000)
- safeRegexOnly: If true, throw an error if the regex is a potentially catastrophic exponential-time regular expression. (Default to false)