function strToRegExp(str) {
    if (str[0] === '/') {
        return new RegExp(str.replace(/^\/|\/$/g, ''));
    }
    return str;
}
Check if the supplied string might be a RegExp and, if so, return the corresponding RegExp.
@param  {String} str     The regex to transform.
@return {RegExp|String}  The final RegExp