Replace every occurrence of a substring.
Numeric.string.replace(text, search, replace)Swaps every match of the search string.
- Parameters:
text: String or array of strings to updatesearch: Substring whose occurrences are replacedreplace: Replacement text inserted for each match
- Returns: Updated strings matching the input shape
- NumPy: Covers
np.strings.replace,np.strings.translate,np.char.replace,np.char.translatethrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const value = Numeric.string.replace('hello', 'l', 'L')
console.log(value)
// heLLoimport Numeric from '@neabyte/numerix'
const value = Numeric.string.replace('hello', 'z', 'Z')
console.log(value)
// helloimport Numeric from '@neabyte/numerix'
const value = Numeric.string.replace('hello', 'l', '')
console.log(value)
// heoimport Numeric from '@neabyte/numerix'
const values = Numeric.string.replace(['hello', 'world'], 'o', '0')
console.log(values)
// ["hell0","w0rld"]