Query with special characters in an ObservableCollection

0

I've created a search method that receives text, and searches that text for a ObservableCollection previously filled in.

    private void btn_Pesquisar_Click(object sender, RoutedEventArgs e)
    {
        ObservableCollection<object> temp = null;

        string oTexto_Pesquisa = txt_Pesquisa.Text.ToLower();
        Regex rgx = new Regex("[^a-zA-Z0-9 -]");
        oTexto_Pesquisa = rgx.Replace(oTexto_Pesquisa, "");


        /*Procurando Marcas*/
        if (WhereToSearch.Equals("Marcas"))
        {
            temp = new ObservableCollection<object>();
            foreach (Marcas marcas in obs_Marcas)
            {
                if (marcas.Nome.ToLower().Contains(oTexto_Pesquisa) || marcas.Descricao == null ? true : marcas.Descricao.ToLower().Contains(oTexto_Pesquisa))
                {
                    temp.Add(new Marcas
                    {
                        Nome = marcas.Nome,
                        Imagem = marcas.Imagem,
                        Descricao = marcas.Descricao
                    });
                }
            }
            Lista_Marcas.ItemsSource = temp;
        }

When searching, the records within this ObservableCollection are returned. But there is a problem with regex ; For example, searching "as" returns the "UTAS" record. But when searching for "as-", it was expected to return the record "AS-Val" but no record is returned and gives no error. How to resolve this search?

    
asked by anonymous 04.09.2017 / 23:04

0 answers