fork(1) download
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4. using System.IO;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = "2.2|[johnnyappleseed@example.com]";
  10. var rx = new Regex(@"(?<=\[)[^]]+");
  11. Console.WriteLine(rx.Match(s).Value);
  12.  
  13. var ss = s.Split('|');
  14. if (ss.GetLength(0) > 1)
  15. {
  16. var last = ss[ss.GetLength(0)-1];
  17. if (last.Contains("[") && last.Contains("@")) // We assume there is an email
  18. Console.WriteLine(last.Trim(new[] {'[', ']'}));
  19. }
  20. }
  21. }
Success #stdin #stdout 0.07s 24536KB
stdin
Standard input is empty
stdout
johnnyappleseed@example.com
johnnyappleseed@example.com