MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / ReplaceAll

Function ReplaceAll

src/tests/coding/cpplint.py:1039–1054  ·  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

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

Callers 2

CheckCommaSpacingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected