<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detag_string(self, string):
 """Extracts tags from string. returns (string, list) where list: list of the removed tags ('<BR>', '<I>', '</I>') """

        counter = itertools.count(0)
        count = lambda m: '<%s>' % next(counter)
        tags = self.tag_pattern.findall(string)
        tags = [''.join(tag) for tag in tags]
        (new, nfound) = self.tag_pattern.subn(count, string)
        if len(tags) != nfound:
            raise Exception('tags dont match:' + string)
        return (new, tags)