Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Problem03Exam05012018
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- const string surfacePattern = @"[^a-zA-Z0-9]+";
- const string mantlePattern = @"[0-9_]+";
- const string corePattern = @"([a-zA-Z]+)";
- var core = string.Empty;
- var input = Console.ReadLine();
- var matcher = Regex.Match(input, $@"^{surfacePattern}$");
- if (!matcher.Success)
- {
- Console.WriteLine("Invalid");
- return;
- }
- input = Console.ReadLine();
- matcher = Regex.Match(input, $@"^{mantlePattern}$");
- if (!matcher.Success)
- {
- Console.WriteLine("Invalid");
- return;
- }
- input = Console.ReadLine();
- var linePattern = $@"^{surfacePattern}{mantlePattern}{corePattern}{mantlePattern}{surfacePattern}$";
- matcher = Regex.Match(input, linePattern);
- if (matcher.Success)
- {
- core = matcher.Groups[1].Value;
- }
- else
- {
- Console.WriteLine("Invalid");
- return;
- }
- input = Console.ReadLine();
- matcher = Regex.Match(input, $@"^{mantlePattern}$");
- if (!matcher.Success)
- {
- Console.WriteLine("Invalid");
- return;
- }
- input = Console.ReadLine();
- matcher = Regex.Match(input, $@"^{surfacePattern}$");
- if (!matcher.Success)
- {
- Console.WriteLine("Invalid");
- return;
- }
- Console.WriteLine("Valid");
- Console.WriteLine(core.Length);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement