Created
March 26, 2012 08:41
-
-
Save kathangeorg/2203950 to your computer and use it in GitHub Desktop.
str_replace Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function str_replace(search, replace, subject) { | |
return subject.split(search).join(replace); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
}