所以现在,re.sub
这样做:
>>> re.sub("DELETE THIS", "", "I want to DELETE THIS472 go to DON'T DELETE THIS847 the supermarket")
"I want to go to DON'T the supermarket"
我希望它只删除“DELETE THISXXX”的第一个实例,其中 XXX 是一个数字,因此结果是
"I want to go to DON'T DELETE THIS847 the supermarket"
XXX 是一个变化的数字,所以我确实需要一个正则表达式。我怎样才能做到这一点?