lib/index.js
function resolveFieldNames (pattern) {
        if(!pattern) { return; }

        var nestLevel = 0;
        var inRangeDef = 0;
        var matched;
        while ((matched = nestedFieldNamesRegex.exec(pattern.resolved)) !== null) {
            switch(matched[0]) {
                case '(':    { if(!inRangeDef) { ++nestLevel; pattern.fields.push(null); } break; }
                case '\\(':  break; // can be ignored
                case '\\)':  break; // can be ignored
                case ')':    { if(!inRangeDef) { --nestLevel; } break; }
                case '[':    { ++inRangeDef; break; }
                case '\\[':  break; // can be ignored
                case '\\]':  break; // can be ignored
                case ']':    { --inRangeDef; break; }
                case '(?:':  // fallthrough                              // group not captured
                case '(?>':  // fallthrough                              // atomic group
                case '(?!':  // fallthrough                              // negative look-ahead
                case '(?<!': { if(!inRangeDef) { ++nestLevel; } break; } // negative look-behind
                default:     { ++nestLevel; pattern.fields.push(matched[2]); break; }
            }
        }

        return pattern;
    }
function resolveFieldNames (pattern) {
        if(!pattern) { return; }

        var nestLevel = 0;
        var inRangeDef = 0;
        var matched;
        while ((matched = nestedFieldNamesRegex.exec(pattern.resolved)) !== null) {
            switch(matched[0]) {
                case '(':    { if(!inRangeDef) { ++nestLevel; pattern.fields.push(null); } break; }
                case '\\(':  break; // can be ignored
                case '\\)':  break; // can be ignored
                case ')':    { if(!inRangeDef) { --nestLevel; } break; }
                case '[':    { ++inRangeDef; break; }
                case '\\[':  break; // can be ignored
                case '\\]':  break; // can be ignored
                case ']':    { --inRangeDef; break; }
                case '(?:':  // fallthrough                              // group not captured
                case '(?>':  // fallthrough                              // atomic group
                case '(?!':  // fallthrough                              // negative look-ahead
                case '(?<!': { if(!inRangeDef) { ++nestLevel; } break; } // negative look-behind
                default:     { ++nestLevel; pattern.fields.push(matched[2]); break; }
            }
        }

        return pattern;
    }
function resolveFieldNames ( pattern ) { if ( ! pattern ) { return ; } var nestLevel = 0 ; var inRangeDef = 0 ; var matched ; while ( ( matched = nestedFieldNamesRegex . exec ( pattern . resolved ) ) !== null ) { switch ( matched [ 0 ] ) { case '(' : { if ( ! inRangeDef ) { ++ nestLevel ; pattern . fields . push ( null ) ; } break ; } case '\\(' : break ; // can be ignored case '\\)' : break ; // can be ignored case ')' : { if ( ! inRangeDef ) { -- nestLevel ; } break ; } case '[' : { ++ inRangeDef ; break ; } case '\\[' : break ; // can be ignored case '\\]' : break ; // can be ignored case ']' : { -- inRangeDef ; break ; } case '(?:' : // fallthrough                              // group not captured case '(?>' : // fallthrough                              // atomic group case '(?!' : // fallthrough                              // negative look-ahead case '(?<!' : { if ( ! inRangeDef ) { ++ nestLevel ; } break ; } // negative look-behind default : { ++ nestLevel ; pattern . fields . push ( matched [ 2 ] ) ; break ; } } } return pattern ; }
create mapping table for the fieldNames to capture
create mapping table for the fieldNames to capture