Anyway, I found one suspected issue:
in your code : you are looping over the first matches collection.
string newcaptureformat = @"\#(?'positionNumber1'\w+)&(?'positionTitle'\w+)&(?'positionDescription'\w+)&(?'companyName'\d+)\s*";
//matching capture format
Regex expr1 = new Regex(newcaptureformat);
MatchCollection matches1 = expr.Matches(sbJobs.ToString());
foreach (Match match in matches) // ??? looping over the first matches collection.
{ //inserting value into table
DataRow newRow = table.Rows.Add();
newRow["positionNumber1"] = int.Parse(match.Groups["positionNumber1"].Value);
newRow["positionTitle"] = match.Groups["positionTitle"].Value;
newRow["positionDescription"] = match.Groups["positionDescription"].Value;
newRow["companyName"] = match.Groups["companyName"].Value;
}
Change it to and check if it works.
string newcaptureformat = @"\#(?'positionNumber1'\w+)&(?'positionTitle'\w+)&(?'positionDescription'\w+)&(?'companyName'\d+)\s*";
//matching capture format
Regex expr1 = new Regex(newcaptureformat);
MatchCollection matches1 = expr.Matches(sbJobs.ToString());
foreach (Match match in matches1)
{ //inserting value into table
DataRow newRow = table.Rows.Add();
newRow["positionNumber1"] = int.Parse(match.Groups["positionNumber1"].Value);
newRow["positionTitle"] = match.Groups["positionTitle"].Value;
newRow["positionDescription"] = match.Groups["positionDescription"].Value;
newRow["companyName"] = match.Groups["companyName"].Value;
}
Please remember to 'Mark as Answer' the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.
No comments:
Post a Comment