fork(35) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.IO;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string data = "1111";
  9. Console.WriteLine(P(data,"(?=(11))"));
  10. }
  11. public static int P(string baseStr, string inputStr)
  12. {
  13. var matches = new Regex(inputStr).Matches(baseStr);
  14. foreach (Match m in matches)
  15. {
  16. Console.WriteLine(string.Format("Найден {1} в позиции {0}", m.Index, m.Groups[1].Value));
  17. }
  18. return new Regex(inputStr).Matches(baseStr).Count;
  19. }
  20. }
Success #stdin #stdout 0.1s 24376KB
stdin
Standard input is empty
stdout
Найден 11 в позиции 0
Найден 11 в позиции 1
Найден 11 в позиции 2
3