Remove accents and symbols with regex

Asked

Viewed 769 times

1

I need to remove the accents and replace the symbol & of that string: "Industry and Trade of manufactured products & aggregates, wells, manufactured and 1º ...", but it doesn’t work properly the way I did:

class Program
    {
        static void Main(string[] args)
        {

            string _textoNAOFormatado = @"Indústria e Comércio de produtos manufaturados & Agregados, poços, fabricados e 1º ...";
            string _pattern = @"(?i)[^0-9a-záéíóúàèìòùâêîôûãõç\s]";
            Regex _rgx = new Regex(_pattern);
            string _textoFormatado = _rgx.Replace(_textoNAOFormatado, "");
            Console.WriteLine("{0}", _textoFormatado);
            Console.ReadKey();
        }
}

Based on that post Regex - Special Character Removal C#, but it doesn’t work, the accents persist and I couldn’t get the &, the return is this:

"Industry and Trade of manufactured products Aggregated wells manufactured and 1 ", need it so: "INDUSTRIA AND WITHAndTRADE IN MANUFACTURED PRODUCTS And PO aggregatesCTHOSE MANUFACTURED AND 1"

  • It is not duplicated, because the difference between the posts is that this question is how to do with regex.

  • It should not be closed. Clearly a different question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.