Skip to content

Instantly share code, notes, and snippets.

@bruno-barros
Last active February 28, 2022 02:40
Show Gist options
  • Save bruno-barros/3973265 to your computer and use it in GitHub Desktop.
Save bruno-barros/3973265 to your computer and use it in GitHub Desktop.
JS: replaceAll
/**
* substitui strings >> replaceAll(str, '.', ':');
* @param string : string utilizada
* @param token : termo buscado
* @param newtoken : termo irá substituir
*/
function replaceAll(string, token, newtoken) {
while (string.indexOf(token) != -1) {
string = string.replace(token, newtoken);
}
return string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment