我有一个包含以下内容的字符串(多行):
"Name=My name
Address=......
\##### To extract from here ####
line 1
line 2
line 3
\##### To extract till here ####
close"
如何提取 "##### To extract *" 字符串之间的行,包括模式?
输出应如下所示:
\##### To extract from here ####
line 1
line 2
line 3
请您参考如下方法:
pat = re.compile('\\\\##### To extract from here ####'
'.*?'
'(?=\\\\##### To extract till here ####)',
re.DOTALL)
或
pat = re.compile(r'\\##### To extract from here ####'
'.*?'
r'(?=\\##### To extract till here ####)',
re.DOTALL)
