lib/xregexp/unicode-base.js
function invertBmp(range) {
        var output = '';
        var lastEnd = -1;

        XRegExp.forEach(
            range,
            /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/,
            function(m) {
                var start = charCode(m[1]);
                if (start > (lastEnd + 1)) {
                    output += '\\u' + pad4(hex(lastEnd + 1));
                    if (start > (lastEnd + 2)) {
                        output += '-\\u' + pad4(hex(start - 1));
                    }
                }
                lastEnd = charCode(m[2] || m[1]);
            }
        );

        if (lastEnd < 0xFFFF) {
            output += '\\u' + pad4(hex(lastEnd + 1));
            if (lastEnd < 0xFFFE) {
                output += '-\\uFFFF';
            }
        }

        return output;
    }
function invertBmp(range) {
        var output = '';
        var lastEnd = -1;

        XRegExp.forEach(
            range,
            /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/,
            function(m) {
                var start = charCode(m[1]);
                if (start > (lastEnd + 1)) {
                    output += '\\u' + pad4(hex(lastEnd + 1));
                    if (start > (lastEnd + 2)) {
                        output += '-\\u' + pad4(hex(start - 1));
                    }
                }
                lastEnd = charCode(m[2] || m[1]);
            }
        );

        if (lastEnd < 0xFFFF) {
            output += '\\u' + pad4(hex(lastEnd + 1));
            if (lastEnd < 0xFFFE) {
                output += '-\\uFFFF';
            }
        }

        return output;
    }
function invertBmp ( range ) { var output = '' ; var lastEnd = - 1 ; XRegExp . forEach ( range , / (\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))? / , function ( m ) { var start = charCode ( m [ 1 ] ) ; if ( start > ( lastEnd + 1 ) ) { output += '\\u' + pad4 ( hex ( lastEnd + 1 ) ) ; if ( start > ( lastEnd + 2 ) ) { output += '-\\u' + pad4 ( hex ( start - 1 ) ) ; } } lastEnd = charCode ( m [ 2 ] || m [ 1 ] ) ; } ) ; if ( lastEnd < 0xFFFF ) { output += '\\u' + pad4 ( hex ( lastEnd + 1 ) ) ; if ( lastEnd < 0xFFFE ) { output += '-\\uFFFF' ; } } return output ; }
Inverts a list of ordered BMP characters and ranges
Inverts a list of ordered BMP characters and ranges