fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. string s = "[1]Ali ahmadi,[2]Mohammad Razavi";
  11. var digits = Regex.Matches(s, @"\[(\d+)\]")
  12. .Cast<Match>()
  13. .Select(m => m.Groups[1].Value)
  14. .ToList();
  15. foreach (var match in digits)
  16. {
  17. Console.WriteLine(match);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 38248KB
stdin
Standard input is empty
stdout
1
2