MCPcopy
hub / github.com/psf/black / re_compile_maybe_verbose

Function re_compile_maybe_verbose

src/black/__init__.py:234–242  ·  view source on GitHub ↗

Compile a regular expression string in `regex`. If it contains newlines, use verbose mode.

(regex: str)

Source from the content-addressed store, hash-verified

232
233
234def re_compile_maybe_verbose(regex: str) -> Pattern[str]:
235 """Compile a regular expression string in `regex`.
236
237 If it contains newlines, use verbose mode.
238 """
239 if "\n" in regex:
240 regex = "(?x)" + regex
241 compiled: Pattern[str] = re.compile(regex)
242 return compiled
243
244
245def validate_regex(

Callers 2

validate_regexFunction · 0.85
get_sourcesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected