实际上我需要获取“--”之间的所有三个文本。所以我写了一个正则表达式如下
import re
def parse_ib_write_bw(mystr):
output = dict()
# match = re.search('--+\n(\n|.)*?--+', mystr, re.I)
match = re.search('--+\n(.*)--+(.*)--+(.*)--+', mystr, re.DOTALL)
if match:
print(match.groups(1))
print(match.groups(2))
print(match.groups(3))
parse_ib_write_bw(my_str)
我的理解是:
--+\n(.*)--+ --> This would give the output of the first block until second '---' is found
(.*)--+ --> would give the second block until the third '--' is found
(.*)--+ --> would give the third block until the final'--' is found
但实际上我得到了整个输出。请帮助我理解我的理解哪里出了问题。