function asXRegExp(value, addFlagX) {
        var flags = addFlagX ? 'x' : '';
        return XRegExp.isRegExp(value) ?
            (value[REGEX_DATA] && value[REGEX_DATA].captureNames ?
                // Don't recompile, to preserve capture names
                value :
                // Recompile as XRegExp
                XRegExp(value.source, flags)
            ) :
            // Compile string as XRegExp
            XRegExp(value, flags);
    }
Converts the provided value to an XRegExp. Native RegExp flags are not preserved.

@private
@param {String|RegExp} value Value to convert.
@param {Boolean} [addFlagX] Whether to apply the `x` flag in cases when `value` is not
  already a regex generated by XRegExp
@returns {RegExp} XRegExp object with XRegExp syntax applied.