当前位置: 首页 > 后端技术 > Python

Python多行正则匹配

时间:2023-03-26 00:55:41 Python

https://python3-cookbook.read...re.compile()函数接受一个名为re.DOTALL的标志参数,在这里非常有用。它允许正则表达式中的点(.)匹配任意字符包括换行page='''justfortestxixihahaforxixihaha'''reg=r'(.*?)'content=re.compile(reg,re.DOTALL)contentlist=content.findall(page)printcontentlist