MCPcopy Create free account
hub / github.com/alibaba/GraphScope / ReplaceAll

Function ReplaceAll

analytical_engine/misc/cpplint.py:1043–1058  ·  view source on GitHub ↗

Replaces instances of pattern in a string with a replacement. The compiled regex is kept in a cache shared by Match and Search. Args: pattern: regex pattern rep: replacement text s: search string Returns: string with replacements made (or original string if no replacements)

(pattern, rep, s)

Source from the content-addressed store, hash-verified

1041
1042
1043def ReplaceAll(pattern, rep, s):
1044 """Replaces instances of pattern in a string with a replacement.
1045
1046 The compiled regex is kept in a cache shared by Match and Search.
1047
1048 Args:
1049 pattern: regex pattern
1050 rep: replacement text
1051 s: search string
1052
1053 Returns:
1054 string with replacements made (or original string if no replacements)
1055 """
1056 if pattern not in _regexp_compile_cache:
1057 _regexp_compile_cache[pattern] = sre_compile.compile(pattern)
1058 return _regexp_compile_cache[pattern].sub(rep, s)
1059
1060
1061def Search(pattern, s):

Callers 2

CheckCommaSpacingFunction · 0.85

Calls 2

compileMethod · 0.80
subMethod · 0.80

Tested by

no test coverage detected