replaceAll

Replaces all occurrences of the searchValue in the str with the replaceValue.

Usage Scenarios

  • Text Replacement: In text editors, replace all instances of a word or phrase.
  • Data Cleaning: Clean data by replacing specific characters or substrings.

Example

import { replaceAll } from 'funtool'

replaceAll('hello world', 'world', 'everyone'); // 'hello everyone'

Signature

function replaceAll(str: string, target: string, replacement: string): string

Parameters

  • str ( string ): The input string.
  • searchValue ( string ): The substring to replace.
  • replaceValue ( string ): The string to replace with.

Returns

  • ( string ): A new string with all occurrences of the search value replaced.