Last active
February 28, 2022 02:40
-
-
Save bruno-barros/3973265 to your computer and use it in GitHub Desktop.
JS: replaceAll
This file contains hidden or 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
/** | |
* 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