I'm creating a routine to search for reserved words in a text (people's names). I have already tested with Contains()
and IndexOf()
. It works well most of the time. However in some words the return does not satisfy. Example: CORALINA returns the reserved word ORAL .
Below the code:
public JsonResult GetPalavrasReservada1(string frase)
{
var palavras = db.TBL_PALAVRA_RESERVADA.Where(pal => pal.PLR_ATIVO == 0).Select(i => new {i.PLR_DESC}).ToList();
var palavrareservada = "";
for (int i = 0; i < palavras.Count; i++)
{
if (frase.ToUpper().Contains(palavras[i].PLR_DESC.ToString()))
{
return Json(palavras[i].PLR_DESC.ToString());
}
}
return Json(palavrareservada);
}
I'm using logic or wrong methods?