(pattern: Pattern)
| 18 | |
| 19 | |
| 20 | def 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 | |
| 38 | def escape_for_regex(text: str) -> str: |
no outgoing calls
no test coverage detected