fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var strs = new List<string> { "[45645]","[5456]","[PB15] [DEC]","[PB16] []"};
  12. foreach (var str in strs) {
  13. var result = Regex.Matches(str, @"\[[^][0-9]*[0-9][^][]*]")
  14. .Cast<Match>()
  15. .Select(x => x.Value)
  16. .ToList();
  17. foreach (var s in result)
  18. Console.WriteLine(s);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.05s 134720KB
stdin
Standard input is empty
stdout
[45645]
[5456]
[PB15]
[PB16]