I have a string similar to "dasdasdsafs[image : image name : image]vvfd gvdfvg dfvgd"
. From this string, I want to remove the part which stars from [image :
and ends at : image]
. I tried to find the 'sub-string' using following code-
result = re.search('%s(.*)%s' % (start, end), st).group(1)
but it doesn't give me the required result. Help me to find the correct way to remove the sub-string from the string.
You can use re.sub
:
>>> s='dasdasdsafs[image : image name : image]vvfd gvdfvg dfvgd'
>>> re.sub(r'\[image.+image\]','',s)
'dasdasdsafsvvfd gvdfvg dfvgd'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With