J
Jon Maz
Hi All,
I want to strip the accents off characters in a string so that, for example,
the (Spanish) word "práctico" comes out as "practico" - but ignoring case,
so that "PRÁCTICO" comes out as "PRACTICO".
What's the best way to do this?
TIA,
JON
--------------------------------------------------
PS First posted to aspmessageboard -
http://www.aspmessageboard.com/forum/regularExpressions.asp?M=705936&T=705936&F=34&P=1 -
no answers yet
PPS The Javascript function that I'm porting to C# looks like this:
function quitaAcentos(a) {
re=new RegExp("á", "gi")
a=a.replace(re, "A")
re=new RegExp("´é", "gi")
a=a.replace(re, "E")
re=new RegExp("í", "gi")
a=a.replace(re, "I")
re=new RegExp("ó", "gi")
a=a.replace(re, "O")
re=new RegExp("ú", "gi")
a=a.replace(re, "U")
re=new RegExp("à", "gi")
a=a.replace(re, "A")
re=new RegExp("è", "gi")
a=a.replace(re, "E")
re=new RegExp("é", "gi")
a=a.replace(re, "E")
re=new RegExp("ì", "gi")
a=a.replace(re, "I")
re=new RegExp("ò", "gi")
a=a.replace(re, "O")
re=new RegExp("ó", "gi")
a=a.replace(re, "O")
re=new RegExp("ù", "gi")
a=a.replace(re, "U")
re=new RegExp("â", "gi")
a=a.replace(re, "A")
re=new RegExp("´ê", "gi")
a=a.replace(re, "E")
re=new RegExp("î", "gi")
a=a.replace(re, "I")
re=new RegExp("ô", "gi")
a=a.replace(re, "O")
re=new RegExp("û", "gi")
a=a.replace(re, "U")
re=new RegExp("ä", "gi")
a=a.replace(re, "A")
re=new RegExp("´ë", "gi")
a=a.replace(re, "E")
re=new RegExp("ï", "gi")
a=a.replace(re, "I")
re=new RegExp("ö", "gi")
a=a.replace(re, "O")
re=new RegExp("ü", "gi")
a=a.replace(re, "U")
re=new RegExp(" ", "gi")
a=a.replace(re, "")
re=new RegExp("_", "gi")
a=a.replace(re, "")
re=new RegExp("ñ", "gi")
a=a.replace(re, "N")
return a
}
I want to strip the accents off characters in a string so that, for example,
the (Spanish) word "práctico" comes out as "practico" - but ignoring case,
so that "PRÁCTICO" comes out as "PRACTICO".
What's the best way to do this?
TIA,
JON
--------------------------------------------------
PS First posted to aspmessageboard -
http://www.aspmessageboard.com/forum/regularExpressions.asp?M=705936&T=705936&F=34&P=1 -
no answers yet
PPS The Javascript function that I'm porting to C# looks like this:
function quitaAcentos(a) {
re=new RegExp("á", "gi")
a=a.replace(re, "A")
re=new RegExp("´é", "gi")
a=a.replace(re, "E")
re=new RegExp("í", "gi")
a=a.replace(re, "I")
re=new RegExp("ó", "gi")
a=a.replace(re, "O")
re=new RegExp("ú", "gi")
a=a.replace(re, "U")
re=new RegExp("à", "gi")
a=a.replace(re, "A")
re=new RegExp("è", "gi")
a=a.replace(re, "E")
re=new RegExp("é", "gi")
a=a.replace(re, "E")
re=new RegExp("ì", "gi")
a=a.replace(re, "I")
re=new RegExp("ò", "gi")
a=a.replace(re, "O")
re=new RegExp("ó", "gi")
a=a.replace(re, "O")
re=new RegExp("ù", "gi")
a=a.replace(re, "U")
re=new RegExp("â", "gi")
a=a.replace(re, "A")
re=new RegExp("´ê", "gi")
a=a.replace(re, "E")
re=new RegExp("î", "gi")
a=a.replace(re, "I")
re=new RegExp("ô", "gi")
a=a.replace(re, "O")
re=new RegExp("û", "gi")
a=a.replace(re, "U")
re=new RegExp("ä", "gi")
a=a.replace(re, "A")
re=new RegExp("´ë", "gi")
a=a.replace(re, "E")
re=new RegExp("ï", "gi")
a=a.replace(re, "I")
re=new RegExp("ö", "gi")
a=a.replace(re, "O")
re=new RegExp("ü", "gi")
a=a.replace(re, "U")
re=new RegExp(" ", "gi")
a=a.replace(re, "")
re=new RegExp("_", "gi")
a=a.replace(re, "")
re=new RegExp("ñ", "gi")
a=a.replace(re, "N")
return a
}