Stan08

MoreRegex/7.Hideout_REGEX.ESCAPE!

Jun 26th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Globalization;
  5. using System.Collections.Generic;
  6. using System.Text;
  7.  
  8. public class Example
  9.  
  10. {
  11. public static void Main(string[] args)
  12.  
  13. {
  14. string map = Console.ReadLine();
  15.  
  16. while(true)
  17. {
  18. string [] clues = Console.ReadLine().Split().ToArray();
  19.  
  20. string trace = Regex.Escape(clues[0])+@"+";
  21.  
  22. MatchCollection m = Regex.Matches(map, trace);
  23.  
  24. foreach (Match tr in m)
  25. {
  26. if (tr.Length>=int.Parse(clues[1]))
  27. {
  28. Console.WriteLine($"Hideout found at index {tr.Index} and it is with size {tr.Length}!");
  29. return;
  30. }
  31. }
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment