Use the replace method by passing regular expressions
const palavra = 'Rádio Mix_São Paulo';
const semEspacos = palavra.replace(/ /g, '_');
console.log(semEspacos);
const semAcentos = semEspacos.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
console.log(semAcentos);
The hardest part to understand here is probably the removing of accents part. First the method normalize
converts the string, transforming accented characters into two separate characters, the letter and the accent. Then the regular expression converts all characters between code 300 and 36f of UTF-8 format (which includes accents) into an empty string.
This can help you on the score withdrawal. https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript. In the space part you can take the variable and make a
replace
._variavel.replace(' ', '_')
.– Victor Henrique