📅  最后修改于: 2022-03-11 14:45:12.663000             🧑  作者: Mango
import re
#Remove the second Hello from example
example = "Hello, world. Hello!"
print re.sub(r'^((.*?Hello.*?){1})Hello', r'\1Goodbye', str)
# Prints "Hello, world. Goodbye!"
#To remove any particular occurance adjust the {1} to the desired number