How is it possible, to replace ŐŰőű
characters to ÖÜöü
in javascript?
This function only replaces the first Ő
character:
str.replace('Ő','ö');
How is it possible, to replace ŐŰőű
characters to ÖÜöü
in javascript?
This function only replaces the first Ő
character:
str.replace('Ő','ö');
Use regular expressions
str = str
.replace(/Ő/g,'ö')
.replace(/Ű/g,'Ü')
.replace(/ő/g,'ö')
.replace(/ű/g,'ü')
You can either use regex (as provider by Claudio Redi) or use global flag 'g':
str.replace("Ő", "ö", "g")
str.replace("Ű", "Ü", "g")
str.replace("ő", "ö", "g")
str.replace("ű", "ü", "g")
see reference
I personally prefer regex. Takes some time to learn them, but it is worth it.