fork download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string s = "8Y4H20M 8H7M 8 h 7 M 19 y 19Y";
  10. MatchCollection result = Regex.Matches(s, @"(?<num>[0-9]+)\s*(?<unit>[mhy])", RegexOptions.IgnoreCase);
  11. foreach (System.Text.RegularExpressions.Match m in result) {
  12. Console.WriteLine("{0} / {1}", m.Groups["unit"].Value, m.Groups["num"].Value);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.03s 30672KB
stdin
Standard input is empty
stdout
Y / 8
H / 4
M / 20
H / 8
M / 7
h / 8
M / 7
y / 19
Y / 19