what is the regex for such a task? –>
replace “[[…:” with “[[”
That is to say, I want to replace *some text * inside [[…: with [[.
The problem with my code is that it remove *text * inside the first [[ ]]
>>> string = "Some text here [[dont remove me]] and some extra text [[remove me:and let this]] here."
>>> clean = re.sub(r'\[\[.+:', '[[', string)
>>> clean
'Some text here [[and let this]] here.'
>>>
[^:\]]is used instead of.to constrain that the stuff to remove is limited within a tag.