Logo Search packages:      
Sourcecode: aap version File versions

def aap-1.090::aapre::MatchObject::group (   self,
  groups 
)

group([group1, group2, ...]) -> string or tuple

Return one or more subgroups of the match. If there is a
single argument, the result is a single string; if there are
multiple arguments, the result is a tuple with one item per
argument. Without arguments, group1 defaults to zero (i.e. the
whole match is returned). If a groupN argument is zero, the
corresponding return value is the entire matching string; if
it is in the inclusive range [1..99], it is the string
matching the the corresponding parenthesized group. If a group
number is negative or larger than the number of groups defined
in the pattern, an IndexError exception is raised. If a group
is contained in a part of the pattern that did not match, the
corresponding result is None. If a group is contained in a
part of the pattern that matched multiple times, the last
match is returned.

If the regular expression uses the (?P<name>...) syntax, the
groupN arguments may also be strings identifying groups by
their group name. If a string argument is not used as a group
name in the pattern, an IndexError exception is raised.

Definition at line 605 of file aapre.py.

00605                             :
        """group([group1, group2, ...]) -> string or tuple

        Return one or more subgroups of the match. If there is a
        single argument, the result is a single string; if there are
        multiple arguments, the result is a tuple with one item per
        argument. Without arguments, group1 defaults to zero (i.e. the
        whole match is returned). If a groupN argument is zero, the
        corresponding return value is the entire matching string; if
        it is in the inclusive range [1..99], it is the string
        matching the the corresponding parenthesized group. If a group
        number is negative or larger than the number of groups defined
        in the pattern, an IndexError exception is raised. If a group
        is contained in a part of the pattern that did not match, the
        corresponding result is None. If a group is contained in a
        part of the pattern that matched multiple times, the last
        match is returned.

        If the regular expression uses the (?P<name>...) syntax, the
        groupN arguments may also be strings identifying groups by
        their group name. If a string argument is not used as a group
        name in the pattern, an IndexError exception is raised.

        """
        if len(groups) == 0:
            groups = (0,)
        result = []
        for g in groups:
            if type(g) == type(''):
                try:
                    g = self.re.groupindex[g]
                except (KeyError, TypeError):
                    raise IndexError, 'group %s is undefined' % `g`
            if g >= len(self.regs):
                raise IndexError, 'group %s is undefined' % `g`
            a, b = self.regs[g]
            if a == -1 or b == -1:
                result.append(None)
            else:
                result.append(self.string[a:b])
        if len(result) > 1:
            return tuple(result)
        elif len(result) == 1:
            return result[0]
        else:
            return ()

    def groupdict(self, default=None):


Generated by  Doxygen 1.6.0   Back to index