MCPcopy Index your code
hub / github.com/microsoft/playwright-python / escape_regex_flags

Function escape_regex_flags

playwright/_impl/_str_utils.py:20–35  ·  view source on GitHub ↗
(pattern: Pattern)

Source from the content-addressed store, hash-verified

18
19
20def escape_regex_flags(pattern: Pattern) -> str:
21 flags = ""
22 if pattern.flags != 0:
23 flags = ""
24 if (pattern.flags & int(re.IGNORECASE)) != 0:
25 flags += "i"
26 if (pattern.flags & int(re.DOTALL)) != 0:
27 flags += "s"
28 if (pattern.flags & int(re.MULTILINE)) != 0:
29 flags += "m"
30 assert (
31 pattern.flags
32 & ~(int(re.MULTILINE) | int(re.IGNORECASE) | int(re.DOTALL) | int(re.UNICODE))
33 == 0
34 ), "Unexpected re.Pattern flag, only MULTILINE, IGNORECASE and DOTALL are supported."
35 return flags
36
37
38def escape_for_regex(text: str) -> str:

Callers 6

clear_cookiesMethod · 0.90
expected_regexFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected