string2regex¶
Converts a string, representing an expression, to a RegExp object
Parameters¶
string - str¶
The string to convert. Must include the slashes.
Return Value¶
A RegExp
object if successful. undefined
on error.
Example Usage¶
import string2regex from '@mvps-genesis/string2regex';
const regex = string2regex( '/[a-z]+/g' );
regex.exec( 'abc!' );