MCPcopy Create free account
hub / github.com/apache/mesos / ReplaceAll

Function ReplaceAll

support/cpplint.py:672–687  ·  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

670
671
672def ReplaceAll(pattern, rep, s):
673 """Replaces instances of pattern in a string with a replacement.
674
675 The compiled regex is kept in a cache shared by Match and Search.
676
677 Args:
678 pattern: regex pattern
679 rep: replacement text
680 s: search string
681
682 Returns:
683 string with replacements made (or original string if no replacements)
684 """
685 if pattern not in _regexp_compile_cache:
686 _regexp_compile_cache[pattern] = sre_compile.compile(pattern)
687 return _regexp_compile_cache[pattern].sub(rep, s)
688
689
690def Search(pattern, s):

Callers 2

CheckCommaSpacingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected