fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. static void Main()
  5. {
  6. Regex r = new Regex(@"\b\d{2}\.\d{2}\.\d{2}\b");
  7. string text1 = "Дата: 12.05.23";
  8. string text2 = "Нет даты";
  9. string text3 = "Дата рождения: 01.01.99";
  10. string text4 = "Некорректная дата: 32.13.22"; // Пример некорректной даты
  11.  
  12. Console.WriteLine(r.IsMatch(text1)); // true
  13. Console.WriteLine(r.IsMatch(text2)); // false
  14. Console.WriteLine(r.IsMatch(text3)); // true
  15. Console.WriteLine(r.IsMatch(text4)); // false
  16. }
  17.  
Success #stdin #stdout 0.03s 21820KB
stdin
Standard input is empty
stdout
Standard output is empty