def extract(self, page, start_index=0, end_index=None,
                ignored_regions=None, **kwargs):
        """
        Find regions bounded by the prefix and suffix and repeatedly
        extract them.
        """
        prefixlen = len(self.prefix)
        suffixlen = len(self.suffix)
        index = max(0, start_index - prefixlen)
        if end_index is None:
            end_index = len(self.template_tokens)
        max_index = min(len(page.page_tokens) - suffixlen,
                        end_index + len(self.suffix))
        max_start_index = max_index - prefixlen
        extracted = []
        region = element_from_page_index(page, start_index)
        surrounding_tag = [region] if region else []
        first = True
        while index <= max_start_index:
            prefix_end = index + prefixlen
            if (page.page_tokens[index:prefix_end] == self.prefix).all():
                for peek in xrange(prefix_end + self.min_jump, max_index + 1):
                    next_prefix = page.page_tokens[peek:peek + prefixlen]
                    next_suffix = page.page_tokens[peek:peek + suffixlen]
                    matches_next_prefix = (next_prefix == self.prefix).all()
                    matches_next_suffix = (next_suffix == self.suffix).all()
                    if not (matches_next_suffix or matches_next_prefix or
                            peek + suffixlen >= max_index):
                        continue
                    if matches_next_prefix:
                        peek -= suffixlen + 1
                    if first:
                        surrounding_tag.append(element_from_page_index(
                            page, index - prefixlen - 1))
                        first = False
                    try:
                        items = []
                        _index = index
                        for extractor in self.extractors:
                            items += extractor.extract(
                                page, index, peek + self.offset,
                                ignored_regions,
                                suffix_max_length=suffixlen)
                            _index = max(peek, index) - 1
                    except MissingRequiredError:
                        pass
                    else:
                        tag = element_from_page_index(page, index)
                        processed = self._process_items(items, page, tag,
                                                        surrounding_tag)
                        extracted.extend(processed)
                    index = _index
                    break
            index += 1
        result = []
        for i, item in enumerate(extracted, 1):
            if not item:
                continue
            try:
                item[u'_index'] = i
            except TypeError:
                pass
            result.append(item)
        if self.parent_annotation.metadata.get('field'):
            return [(self.parent_annotation.metadata['field'], result)]
        return result

        Find regions bounded by the prefix and suffix and repeatedly
        extract them.
        
slybot/slybot/plugins/scrapely_annotations/extraction/container_extractors.py