fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string pattern = @"\bP-?([0-9]+)\b";
  10. string s = @"1. G66I11.J270.P5.C90.(+K2H1+)
  11. 2. G66I11.J90.P-5.(+K2H1+)
  12. 3. G66I215.4J270.P-55.Q-6.T2531(+K2H1+)";
  13. var numbers = Regex.Matches(s, pattern)
  14. .Select(i => int.Parse(i.Groups[1].Value))
  15. .ToArray();
  16. Console.WriteLine("[{0}]", string.Join(", ", numbers));
  17. }
  18. }
Success #stdin #stdout 0.06s 28564KB
stdin
Standard input is empty
stdout
[5, 5, 55]