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

Function escape_regex_for_selector

playwright/_impl/_str_utils.py:42–51  ·  view source on GitHub ↗
(text: Pattern)

Source from the content-addressed store, hash-verified

40
41
42def escape_regex_for_selector(text: Pattern) -> str:
43 # Even number of backslashes followed by the quote -> insert a backslash.
44 return (
45 "/"
46 + re.sub(r'(^|[^\\])(\\\\)*(["\'`])', r"\1\2\\\3", text.pattern).replace(
47 ">>", "\\>\\>"
48 )
49 + "/"
50 + escape_regex_flags(text)
51 )
52
53
54def escape_for_text_selector(

Callers 2

escape_for_text_selectorFunction · 0.85

Calls 1

escape_regex_flagsFunction · 0.85

Tested by

no test coverage detected