c# - Regex to parse string input -
i want use regex parse groups
string input = @"(1,2)(3,4)"; regex.matches(input, @"\((\d,\d)\)");
the results not 1,2 , 3,4 spaces. can guys me ?
edit:
i want 2 groups 1,2 , 3,4.
string input = @"(1,2)(3,4)"; matchcollection inputmatch= regex.matches(collegerecord.tostring(), @"(?<=\().*?(?=\))");
for current string 2 outputs:
inputmatch[0].groups[0].value; inputmatch[0].groups[1].value;
or
you can try foreach loop
foreach (match match in inputmatch) { }
i have not tested code,
my working example:
matchcollection facilities = regex.matches(collegerecord.tostring(), @"<td width=""38"">(.*?)image_tooltip"); foreach (match facility in facilities) { collegedetaildh.insertfacilitydetails(collegedetaildh._collegeid, facility.tostring().replace("<td width=\"38\">", string.empty).replace("<span class=\"icon_", string.empty).replace("image_tooltip", string.empty)); }
Comments
Post a Comment