例子如下:
a = "one two three four five six one three four seven two"
m = re.search("one.*four", a)
我想要的是找到从“一”到“四”之间不包含子串“二”的子串。 答案应该是:m.group(0) = "一三四", m.start() = 28, m.end() = 41
有没有一种方法可以用一个搜索行来做到这一点?
最佳答案
关于Python 正则表达式 : find a substring that doesn't contain a substring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19750096/