I need to check if a string contains a diacritic, so if I have a name "Kateřina" I need to return true and if I have "Jana" I need false. For both values I get false now. Please I don't want to remove them I want to keep them so string normalize won't do, basically I need to check if string has these ěščřžýáíé
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string name = "Jana";
string name2 = "Kateřina";
if (ExTest.DiacriticCheck(name))
{
Console.WriteLine(name);
}
if (ExTest.DiacriticCheck(name2))
{
Console.WriteLine(name2);
}
}
public static bool DiacriticCheck(string text)
{
if (Regex.IsMatch(text, @"^[\p{L}\p{N}\p{Zs}_-]+$ˇ") == false)
{
return false;
}
return true;
}