lib/Globby/Tokenizer/Glob.php
protected function createInitialDefinition()
    {
        return [
            /*
             * Match against non-special characters. To explain the components of this:
             *
             * [^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*
             *  - This matches non-special (\*[?) characters. If it matches one, it'll permit it to be an escape
             *    (i.e. \) if a character exists after it (which may be "special"). This then returns to the previous
             *    matching pattern, repeating the same rules until a non-escaped "special" character is hit.
             *
             * (?:\\\\.[^\\\\*\[?]*)+
             *  - This immediately looks for escape characters, as the previous component of this regex requires for the
             *    initial character to be non-special. This then returns to the standard rules the previous regex.
             */
            '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self::T_WORD,
            // Simple match of "*"
            '\*' => self::T_WILDCARD_MULTI,
            // Simple match of "?"
            '\?' => self::T_WILDCARD_SINGLE,
            /*
             * Matches against [. This also optionally matches "!" or "^" as the first character to provide negation
             * context. The positive lookahead provides a means to check for "]" as the first character. This is a
             * slightly nasty hack to deal with a rule that "]" can be permitted as a standard character in a character,
             * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such
             * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure
             * it's captured by adding a capturing group inside (regex lookarounds do not capture).
             */
            '\[([!^]?)(?=(\])?)' => function (Stateful $lexer, $matches) {
                // Determine the state to enter (depending on whether the lookahead succeeded, i.e. "]" is the first
                // character of the grouping)
                $state = isset($matches[2])
                    ? 'IN_GROUP_SPECIAL_FIRST'
                    : 'IN_GROUP';

                $lexer->pushState($state);

                // Negated grouping if the first character is "!"
                return $matches[1] !== ''
                    ? self::T_GROUP_BEGIN_NEGATED
                    : self::T_GROUP_BEGIN;
            }
        ];
    }
protected function createInitialDefinition()
    {
        return [
            /*
             * Match against non-special characters. To explain the components of this:
             *
             * [^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*
             *  - This matches non-special (\*[?) characters. If it matches one, it'll permit it to be an escape
             *    (i.e. \) if a character exists after it (which may be "special"). This then returns to the previous
             *    matching pattern, repeating the same rules until a non-escaped "special" character is hit.
             *
             * (?:\\\\.[^\\\\*\[?]*)+
             *  - This immediately looks for escape characters, as the previous component of this regex requires for the
             *    initial character to be non-special. This then returns to the standard rules the previous regex.
             */
            '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self::T_WORD,
            // Simple match of "*"
            '\*' => self::T_WILDCARD_MULTI,
            // Simple match of "?"
            '\?' => self::T_WILDCARD_SINGLE,
            /*
             * Matches against [. This also optionally matches "!" or "^" as the first character to provide negation
             * context. The positive lookahead provides a means to check for "]" as the first character. This is a
             * slightly nasty hack to deal with a rule that "]" can be permitted as a standard character in a character,
             * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such
             * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure
             * it's captured by adding a capturing group inside (regex lookarounds do not capture).
             */
            '\[([!^]?)(?=(\])?)' => function (Stateful $lexer, $matches) {
                // Determine the state to enter (depending on whether the lookahead succeeded, i.e. "]" is the first
                // character of the grouping)
                $state = isset($matches[2])
                    ? 'IN_GROUP_SPECIAL_FIRST'
                    : 'IN_GROUP';

                $lexer->pushState($state);

                // Negated grouping if the first character is "!"
                return $matches[1] !== ''
                    ? self::T_GROUP_BEGIN_NEGATED
                    : self::T_GROUP_BEGIN;
            }
        ];
    }
protected function createInitialDefinition ( ) { return [ /*
             * Match against non-special characters. To explain the components of this:
             *
             * [^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*
             *  - This matches non-special (\*[?) characters. If it matches one, it'll permit it to be an escape
             *    (i.e. \) if a character exists after it (which may be "special"). This then returns to the previous
             *    matching pattern, repeating the same rules until a non-escaped "special" character is hit.
             *
             * (?:\\\\.[^\\\\*\[?]*)+
             *  - This immediately looks for escape characters, as the previous component of this regex requires for the
             *    initial character to be non-special. This then returns to the standard rules the previous regex.
             */ '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self :: T_WORD , // Simple match of "*" '\*' => self :: T_WILDCARD_MULTI , // Simple match of "?" '\?' => self :: T_WILDCARD_SINGLE , /*
             * Matches against [. This also optionally matches "!" or "^" as the first character to provide negation
             * context. The positive lookahead provides a means to check for "]" as the first character. This is a
             * slightly nasty hack to deal with a rule that "]" can be permitted as a standard character in a character,
             * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such
             * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure
             * it's captured by adding a capturing group inside (regex lookarounds do not capture).
             */ '\[([!^]?)(?=(\])?)' => function ( Stateful $ lexer , $ matches ) { // Determine the state to enter (depending on whether the lookahead succeeded, i.e. "]" is the first // character of the grouping) $ state = isset ( $ matches [ 2 ] ) ? 'IN_GROUP_SPECIAL_FIRST' : 'IN_GROUP' ; $ lexer -> pushState ( $ state ) ; // Negated grouping if the first character is "!" return $ matches [ 1 ] !== '' ? self :: T_GROUP_BEGIN_NEGATED : self :: T_GROUP_BEGIN ; } ] ; }
Initial state. This is the default state when the lexer enters the pattern.

@return array
Initial state . This is the default state when the lexer enters the pattern .