MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / ReplaceAll

Function ReplaceAll

steps/cpplint.py:1054–1069  ·  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

1052
1053
1054def ReplaceAll(pattern, rep, s):
1055 """Replaces instances of pattern in a string with a replacement.
1056
1057 The compiled regex is kept in a cache shared by Match and Search.
1058
1059 Args:
1060 pattern: regex pattern
1061 rep: replacement text
1062 s: search string
1063
1064 Returns:
1065 string with replacements made (or original string if no replacements)
1066 """
1067 if pattern not in _regexp_compile_cache:
1068 _regexp_compile_cache[pattern] = sre_compile.compile(pattern)
1069 return _regexp_compile_cache[pattern].sub(rep, s)
1070
1071
1072def Search(pattern, s):

Callers 2

CheckCommaSpacingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected