私は正規表現を使用していましたが、これを書きました:
static void Main(string[] args)
{
string test = "this a string meant to test long space recognition n a";
Regex regex = new Regex(@"[a-z][\s]{4,}[a-z]$");
MatchCollection matches = regex.Matches(test);
if (matches.Count > 1)
Console.WriteLine("yes");
else
{
Console.WriteLine("no");
Console.WriteLine("the number of matches is "+matches.Count);
}
}
私の意見では、Matches メソッドは "n n" と "n a" の両方を見つける必要があります。それにもかかわらず、それは「n n」を見つけることしかできず、なぜそれが理解できない..