MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / ReplaceAll

Function ReplaceAll

rtpose_wrapper/scripts/cpp_lint.py:525–540  ·  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

523
524
525def ReplaceAll(pattern, rep, s):
526 """Replaces instances of pattern in a string with a replacement.
527
528 The compiled regex is kept in a cache shared by Match and Search.
529
530 Args:
531 pattern: regex pattern
532 rep: replacement text
533 s: search string
534
535 Returns:
536 string with replacements made (or original string if no replacements)
537 """
538 if pattern not in _regexp_compile_cache:
539 _regexp_compile_cache[pattern] = sre_compile.compile(pattern)
540 return _regexp_compile_cache[pattern].sub(rep, s)
541
542
543def Search(pattern, s):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected