Decide whether to treat `to_replace` as a regular expression.
(regex: bool, to_replace: Any)
| 30 | |
| 31 | |
| 32 | def should_use_regex(regex: bool, to_replace: Any) -> bool: |
| 33 | """ |
| 34 | Decide whether to treat `to_replace` as a regular expression. |
| 35 | """ |
| 36 | if is_re(to_replace): |
| 37 | regex = True |
| 38 | |
| 39 | regex = regex and is_re_compilable(to_replace) |
| 40 | |
| 41 | # Don't use regex if the pattern is empty. |
| 42 | regex = regex and re.compile(to_replace).pattern != "" |
| 43 | return regex |
| 44 | |
| 45 | |
| 46 | def compare_or_regex_search( |
no test coverage detected