lib/util-x.js
function copyRegExp(regExpArg, options) {
            var flags;

            if (!isPlainObject(options)) {
                options = {};
            }

            // Get native flags in use
            flags = onlyCoercibleToString(pExec.call(getNativeFlags, $toString(regExpArg))[1]);
            if (options.add) {
                flags = pReplace.call(flags + options.add, clipDups, '');
            }

            if (options.remove) {
                // Would need to escape `options.remove` if this was public
                flags = pReplace.call(flags, new CRegExp('[' + options.remove + ']+', 'g'), '');
            }

            return new CRegExp(regExpArg.source, flags);
        }
function copyRegExp(regExpArg, options) {
            var flags;

            if (!isPlainObject(options)) {
                options = {};
            }

            // Get native flags in use
            flags = onlyCoercibleToString(pExec.call(getNativeFlags, $toString(regExpArg))[1]);
            if (options.add) {
                flags = pReplace.call(flags + options.add, clipDups, '');
            }

            if (options.remove) {
                // Would need to escape `options.remove` if this was public
                flags = pReplace.call(flags, new CRegExp('[' + options.remove + ']+', 'g'), '');
            }

            return new CRegExp(regExpArg.source, flags);
        }
function copyRegExp ( regExpArg , options ) { var flags ; if ( ! isPlainObject ( options ) ) { options = { } ; } // Get native flags in use flags = onlyCoercibleToString ( pExec . call ( getNativeFlags , $toString ( regExpArg ) ) [ 1 ] ) ; if ( options . add ) { flags = pReplace . call ( flags + options . add , clipDups , '' ) ; } if ( options . remove ) { // Would need to escape `options.remove` if this was public flags = pReplace . call ( flags , new CRegExp ( '[' + options . remove + ']+' , 'g' ) , '' ) ; } return new CRegExp ( regExpArg . source , flags ) ; }
Copies a regex object. Allows adding and removing native flags while copying the regex.
@private
@function copyRegExp
@param {RegExp} regex Regex to copy.
@param {Object} [options] Allows specifying native flags to add or remove while copying the regex.
@returns {RegExp} Copy of the provided regex, possibly with modified flags.
Copies a regex object . Allows adding and removing native flags while copying the regex .