A suite to track Project Diva score statistics and ratings / D4DJ event data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
projectdivar/server/node_modules/utils-regex-from-string/lib/index.js

32 lines
757 B

'use strict';
// MODULES //
var isString = require( 'validate.io-string-primitive' ),
RE = require( 'regex-regex' );
// REGEX //
/**
* FUNCTION: regex( str )
* Parses a regular expression string and returns a new regular expression.
*
* @param {String} str - regular expression string
* @returns {RegExp|Null} regular expression or null
*/
function regex( str ) {
if ( !isString( str ) ) {
throw new TypeError( 'invalid input argument. Must provide a regular expression string. Value: `' + str + '`.' );
}
// Capture the regular expression pattern and any flags:
str = RE.exec( str );
// Create a new regular expression:
return ( str ) ? new RegExp( str[1], str[2] ) : null;
} // end FUNCTION regex()
// EXPORTS //
module.exports = regex;