Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个
开始 [一些文本] 结尾
保留所有空格
re.match(r'begin(.*)end', text, re.DOTALL).group(1)
在“开始”和“结束”之前忽略空格:
re.match(r'begin\s*(.*)\s*end', text, re.DOTALL).group(1)
这假定text始终包含匹配项并以“开始”开头。
text