I have a string as below
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\"}";
from the above string i need to find the repeating text "Error importing username:" and take the username value next to it along with corresponding email id after the text "primary email:" and store it in in datatable with expected output as below
Expected Result in Datatable as below
username primary email
3167763 pkumar194@google.com
3195330 alejandra.mejia@google.com
below is the code sample i have where i can able to get all the username in list i need to modify the below code to get both username and corresponding primary email id as well in a collection your help will be very much useful
List<int> list = Regex.Matches(error_message, @"(?<=Error importing username: )\d+")
.Cast<Match>()
.Select(match => int.Parse(match.Value))
.ToList();