I have a text, let's say:
Lorem ipsum dolor sit [[amet]], consectetur adipiscing elit,
sed do eiusmod [[time (sample)|tempor]] incididunt ut [[labore]] et dolore magna aliqua.
I want to replace the [[time (sample)|tempor]] with tempor.
The structure is always the same: [[string to remove|string to extract]] and can appear several times in the text.
I tried regular expressions in regex, but I wasn't successful without cutting off half of the text: re.sub(r'\[.*?\|', '', text)
How can I replace the string?