Skip to content

Instantly share code, notes, and snippets.

@Elorucov
Last active August 7, 2022 21:28
Show Gist options
  • Select an option

  • Save Elorucov/2cc278d8e154cc49f4f873baca44c4b8 to your computer and use it in GitHub Desktop.

Select an option

Save Elorucov/2cc278d8e154cc49f4f873baca44c4b8 to your computer and use it in GitHub Desktop.
Detect Z and V letters in cyrillic words.
// ELOR 2022.
using System;
using System.Text.RegularExpressions;
public class Program {
public static void Main() {
Console.WriteLine($"Result: {CheckIsBrainwashed("Залупа Zа Vойну! Хи-хи.")}");
}
static readonly Regex Reg1 = new Regex(@"^[А-яЁёZzVv\d\W]+$");
static readonly Regex Reg2 = new Regex(@"^[А-яЁё\d\W]+$");
private static bool CheckIsBrainwashed(string str) {
string[] words = str.Split(' ');
bool detected = false;
for (int i = 0; i < words.Length; i++) {
string word = words[i];
bool m1 = Reg1.IsMatch(word);
bool m2 = Reg2.IsMatch(word);
Console.WriteLine($"{i}: {word} ({m1}/{m2})");
if (m1 && !m2) {
detected = true;
break;
}
}
return detected;
}
}
@k1zn
Copy link

k1zn commented Aug 7, 2022

о спасибо тебе великий за этот замечательный гист, ведь ни один человек не осилил бы создать регулярки и проверять их 🙏🙏🙏🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment