fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. MatchThis("H12345678ABC");
  8. MatchThis("G123456789ABC");
  9. }
  10. private static void MatchThis(string subject)
  11. {
  12. var regex = new Regex(@"(?((?<hgroup>H))\k<hgroup>.{8}|.{10})(?<user>.*)");
  13. var match =regex.Match(subject);
  14. if(match.Success)
  15. {
  16. Console.WriteLine(match.Groups["user"].Value);//prints ABC
  17. }
  18. else
  19. {
  20. Console.WriteLine("No Match");
  21. }
  22. }
  23. }
Success #stdin #stdout 0.07s 33688KB
stdin
Standard input is empty
stdout
ABC
ABC