Elh*_*bib 10 python python-3.x python-re
谁能告诉我是否可以组合re.IGNORECASE、re.MULTILINE和 等标志re.DOTALL来进行正则表达式匹配?
r = re.compile(regex, re.IGNORECASE | re.MULTILINE | re.DOTALL)
Run Code Online (Sandbox Code Playgroud)
我需要根据用例匹配整个段落或一行中的表达式。
是的,您可以将正则表达式标志与|.
文档https://docs.python.org/3/library/re.html#re.compile特别指出:
\n\n\n可以通过指定标志值来修改表达式\xe2\x80\x99s 的行为。值可以是以下任何变量,使用按位 OR(
\n|运算符)组合。
| 归档时间: |
|
| 查看次数: |
2477 次 |
| 最近记录: |