'Extracts tags from string.
returns (string, list) where
string: string has tags replaced by indices (<BR>... => <0>, <1>, <2>, etc.)
list: list of the removed tags (\'<BR>\', \'<I>\', \'</I>\')'

def detag_string(self, string):

    counter = itertools.count(0)
    count = (lambda m: ('<%s>' % counter.next()))
    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)
