def scan_regexp(self, space, w_pattern):
        last = -1
        string = space.str_w(self)
        ctx = w_pattern.make_ctx(string)

        while last < len(string) and self.search_context(space, ctx):
            w_matchdata = w_pattern.get_match_result(space, ctx, string, found=True)
            if w_matchdata.size() > 1:
                matches_w = []
                for num in xrange(1, w_matchdata.size(), 1):
                    begin, end = w_matchdata.get_span(num)
                    assert begin >= 0
                    assert end >= 0
                    w_str = space.newstr_fromstr(string[begin:end])
                    space.infect(w_str, self)
                    space.infect(w_str, w_pattern)
                    matches_w.append(w_str)
                w_match = space.newarray(matches_w)
            else:
                w_match = space.newstr_fromstr(string[ctx.match_start:ctx.match_end])
                space.infect(w_match, self)
                space.infect(w_match, w_pattern)

            yield w_match

            if ctx.match_start == ctx.match_end:
                last += 1
            else:
                last = ctx.match_end
            assert last >= 0
            ctx.reset(last)
dataset/ETHPy150Open topazproject/topaz/topaz/objects/stringobject.py/W_StringObject.scan_regexp/original