Advertisement
istomina_sofia

С# регулярные выражения

Mar 1st, 2022
1,383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Лаба_8
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             TryAgain:
  11.             Console.Write("Введите идентификатор цвета в HTML: ");
  12.             string line = Console.ReadLine();
  13.  
  14.             Regex regex = new Regex(@"^#([0-9A-Fa-f]){6}$");
  15.             Console.WriteLine("{0} {1}индетификатор цвета",line,  regex.IsMatch(line) ? "" : "не ");
  16.  
  17.             if (regex.IsMatch(line) == false)
  18.             {
  19.                 Console.WriteLine("Ошибка при вводе идентификатора, повторите!\n");
  20.                 goto TryAgain;
  21.             }
  22.         }
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement