This looks risky. Why not a regex instead? E.g. `re.findall(err, '\[\[(.*?)\]\]')` or something.