Skip to content

Instantly share code, notes, and snippets.

@kathangeorg
Created March 26, 2012 08:41
Show Gist options
  • Save kathangeorg/2203950 to your computer and use it in GitHub Desktop.
Save kathangeorg/2203950 to your computer and use it in GitHub Desktop.
str_replace Javascript
function str_replace(search, replace, subject) {
return subject.split(search).join(replace);
}
@zaqi-ubuy
Copy link

you can use this.
export const str_replace = (search: string[], replace: string[], str: string) =>{
search.forEach((a: string,i: number)=>{
str = str.replace(a, replace[i])
})
return str
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment