MCPcopy Create free account
hub / github.com/BVLC/caffe / ReplaceAll

Function ReplaceAll

scripts/cpp_lint.py:529–544  ·  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

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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected