'Takes a pattern, checks if it has a subscript, and returns the pattern
without the subscript and a (start,end) tuple representing the given
subscript (or None if there is no subscript).
Validates that the subscript is in the right syntax, but doesn\'t make
sure the actual indices make sense in context.'

def _split_subscript(self, pattern):

    if pattern.startswith('~'):
        return (pattern, None)
    pattern_with_subscript = re.compile('^\n                                                                (.+)                                                                                #    A    pattern    expression    ending    with...\n                                                                \\[(?:                                                                            #    A    [subscript]    expression    comprising:\n                                                                                (-?[0-9]+)|                                    #    A    single    positive    or    negative    number\n                                                                                ([0-9]+)([:-])                        #    Or    an    x:y    or    x:    range.\n                                                                                ([0-9]*)\n                                                                )\\]\n                                                                $\n                                                ', re.X)
    subscript = None
    m = pattern_with_subscript.match(pattern)
    if m:
        (pattern, idx, start, sep, end) = m.groups()
        if idx:
            subscript = (int(idx), None)
        else:
            if (not end):
                end = (-1)
            subscript = (int(start), int(end))
            if (sep == '-'):
                display.warning('Use    [x:y]    inclusive    subscripts    instead    of    [x-y]    which    has    been    removed')
    return (pattern, subscript)
