There are strings in Stack Exchange Markdown that need to be removed (set to null string). I think Python RegEx would be the best solution. Here are the strings:
[![male end][1]][1]
[![female end][2]][2]
It probably doesn't matter to those familiar with Stack Exchange Markdown but the original markdown above can be found in this post in Stack Exchange Electrical Engineering.
Note that [![
prefix is for a picture link. Other links will be [[
or even [
prefix.
CodePudding user response:
Use re.sub
to remove each markup tag:
inp = "Hello [![male end][1]][1] World [![female end][2]][2] Goodbye"
output = re.sub(r'\[!\[.*?\]\[\d \]\]\[\d \]', '', inp)
print(output) # Hello World Goodbye