Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace _03.CameraView
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int m = numbers[0]; //skip
- int n = numbers[1]; //take
- string input = Console.ReadLine();
- //string pattern = $@"\|< ([\w]{m})([\w]{ 0,{n}})";
- string pattern = @"\|<([\w]{" + m + @"})([\w]{0,"+ n + @"})"; //още един начин да се вмъкне променлива в regex
- MatchCollection myMatches = Regex.Matches(input, pattern);
- List<string> result = new List<string>();
- foreach (Match myM in myMatches)
- {
- result.Add(myM.Groups[2].Value); //тук броенето е от 1. Патерна е разделен на групи от ()
- }
- Console.WriteLine(string.Join(", ",result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement