MCPcopy Create free account
hub / github.com/tensorflow/tfjs / ReplaceAll

Function ReplaceAll

tfjs-backend-wasm/tools/cpplint.py:667–682  ·  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

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

Callers 2

CheckCommaSpacingFunction · 0.85

Calls 2

subMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…