EmoRz

Camera_View

Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace CameraView
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.            //https://softuni.bg/downloads/svn/soft-tech/May-2017/Programming-Fundamentals-May-2017/12.%20Programming-Fundamentals-Regular-Expressions/12.%20Programming-Fundamentals-Regular-Expressions-Regex-Exercise.docx//
  13.             int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.             // 9, 7
  15.             string input = Console.ReadLine();
  16.             string pattern = @"\|<([a-zA-Z]+)";
  17.             //GreatBigSea|<uglyStuffHawaii|<boriiiingKilauea
  18.             MatchCollection pictureDada = new Regex(pattern).Matches(input);
  19.             List<string> str = new List<string>();
  20.             string temp = "";
  21.             foreach (Match picture in pictureDada)
  22.             {
  23.                 string pic = picture.Groups[1].Value.Trim();
  24.                 var result = pic.Skip(numbers[0]).Take(numbers[1]);
  25.                 foreach (var item in result)
  26.                 {
  27.                     temp += item;
  28.                 }
  29.                 str.Add(temp);
  30.                 temp = "";
  31.             }
  32.             Console.WriteLine(string.Join(", ", str));
  33.  
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment