kalitarix

Snowflake

Jan 27th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Snowflake_01_18
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string surface1 = Console.ReadLine();
  11.             string mantle1 = Console.ReadLine();
  12.             string core = Console.ReadLine();
  13.             string mantle2 = Console.ReadLine();
  14.             string surface2 = Console.ReadLine();
  15.  
  16.             string patternSurface = @"^[^A-Za-z0-9]+$";
  17.  
  18.             Match matchSurface1 = Regex.Match(surface1, patternSurface);
  19.             Match matchSurface2 = Regex.Match(surface2, patternSurface);
  20.  
  21.             if (matchSurface1.Success == false || matchSurface2.Success == false)
  22.             {
  23.                 Console.WriteLine("Invalid");
  24.                 return;
  25.             }
  26.  
  27.             string patternMantle = @"^[0-9_]+$";
  28.  
  29.             Match matchMantle1 = Regex.Match(mantle1, patternMantle);
  30.             Match matchMantle2 = Regex.Match(mantle2, patternMantle);
  31.  
  32.             if (matchMantle1.Success == false || matchMantle2.Success == false)
  33.             {
  34.                 Console.WriteLine("Invalid");
  35.                 return;
  36.             }
  37.  
  38.             string patternCore = @"^([^A-Za-z0-9]+)([0-9_]+)(?<core>[A-Za-z]+)([0-9_]+)([^A-Za-z0-9]+)$";
  39.  
  40.             Match matchCore = Regex.Match(core, patternCore);
  41.  
  42.             if (matchCore.Success == false)
  43.             {
  44.                 Console.WriteLine("Invalid");
  45.                 return;
  46.             }
  47.  
  48.             string validCore = matchCore.Groups["core"].ToString();
  49.  
  50.             Console.WriteLine("Valid");
  51.             Console.WriteLine(validCore.Length);
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment