fork download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string pattern = @"\bError importing username: (\d+), primary email: ([^\s@]+@[^\s@,]+)";
  10. string input = @"string error_message= ""{\""2705\"":\""Error importing username: 3167763, primary email: pkumar194@google.com, error: User already exists but Email does not match: pkumar194@googlee.com vs pkumar193@google.co.in\"",\""10001\"":\""Error importing username: 3195330, primary email: alejandra.mejia@google.com, error: User already exists but Email does not match: alejandra.mejia@google.com vs alejandra.mejia@googlee.com\""}"";";
  11.  
  12. var collection = Regex.Matches(input, pattern)
  13. .Cast<Match>()
  14. .Select(match =>
  15. new {username = int.Parse(match.Groups[1].Value), primary_email = match.Groups[2].Value}
  16. );
  17.  
  18. foreach (var item in collection) {
  19. Console.WriteLine("username: {0}, primary email: {1}",
  20. item.username,
  21. item.primary_email
  22. );
  23. }
  24. }
  25. }
Success #stdin #stdout 0.06s 22200KB
stdin
Standard input is empty
stdout
username: 3167763, primary email: pkumar194@google.com
username: 3195330, primary email: alejandra.mejia@google.com