I have this regex to replace accents but it fails if the text contains "|".
string Text = "word|word2";
string Text = "word|word2";
C#
Copy Code
// Regex. System.Text.RegularExpressions.Regex replace_a_Accents = new System.Text.RegularExpressions.Regex("[á|à|ä|â]", System.Text.RegularExpressions.RegexOptions.Compiled); System.Text.RegularExpressions.Regex replace_e_Accents = new System.Text.RegularExpressions.Regex("[é|è|ë|ê]", System.Text.RegularExpressions.RegexOptions.Compiled); System.Text.RegularExpressions.Regex replace_i_Accents = new System.Text.RegularExpressions.Regex("[í|ì|ï|î]", System.Text.RegularExpressions.RegexOptions.Compiled); System.Text.RegularExpressions.Regex replace_o_Accents = new System.Text.RegularExpressions.Regex("[ó|ò|ö|ô]", System.Text.RegularExpressions.RegexOptions.Compiled); System.Text.RegularExpressions.Regex replace_u_Accents = new System.Text.RegularExpressions.Regex("[ú|ù|ü|û]", System.Text.RegularExpressions.RegexOptions.Compiled);// Reemplaza. Texto_Retorno = replace_a_Accents.Replace(Texto_Retorno, "a"); Texto_Retorno = replace_e_Accents.Replace(Texto_Retorno, "e"); Texto_Retorno = replace_i_Accents.Replace(Texto_Retorno, "i"); Texto_Retorno = replace_o_Accents.Replace(Texto_Retorno, "o"); Texto_Retorno = replace_u_Accents.Replace(Texto_Retorno, "u");