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 and store it in int<list>
or in datatable with expected output as below
3167763
3195330
i have tried with below code but its working only when the ""Error importing username:" text appear once but in my case that text is reapeating and i need to get all the username in a list
Your help is very much needed ,Thanks in Advance
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\"}";
string strStart = "Error importing username:";
string strEnd = ",";
if (error_msg.Contains(strStart) && error_msg.Contains(strEnd))
{
int Start = error_msg.IndexOf(strStart) + strStart.Length;
int End = error_msg.IndexOf(strEnd, Start);
return error_msg.Substring(Start, End - Start);
}