谁能告诉我是否可以组合像 re.IGNORECASE
这样的标志, re.MULTILINE
和 re.DOTALL
正则表达式匹配?
r = re.compile(regex, re.IGNORECASE | re.MULTILINE | re.DOTALL)
我需要根据用例在一行中匹配整个段落或表达式。
最佳答案
是的,您可以将正则表达式标志与 |
结合使用.
文档 https://docs.python.org/3/library/re.html#re.compile具体说:
The expression’s behaviour can be modified by specifying a flags value. Values can be any of the following variables, combined using bitwise OR (the
|
operator).
关于python - 组合重新标记 re.IGNORECASE、re.MULTILINE 和 re.DOTALL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66139972/