我有一个类似于"dasdasdsafs[image : image name : image]vvfd gvdfvg dfvgd"
的字符串。从这个字符串中,我想删除从[image :
到: image]
星星的部分。我试图找到使用以下代码的'子串' -查找并移除以python中的特定子字符串开始和结尾的字符串
result = re.search('%s(.*)%s' % (start, end), st).group(1)
但它没有给我所需的结果。 帮我找到从字符串中删除子字符串的正确方法。
看看[移除子(https://stackoverflow.com/questions/8703017/remove-sub-string-by-using-python)或[子在python](HTTPS:/ /stackoverflow.com/questions/663171/is-there-a-way-to-substring-a-string-in-python?rq=1)然后[查找字符串中的字符索引](https:// stackoverflow.com/questions/2294493/how-to-get-the-position-of-a-character-in-python) – JGreenwell