I am trying to get some text surrounded by <td>
tags. My problem is that I am able to fetch the first result only, and can't get others.
From the following HTML, I only get the 1st result which is this text:
Student Name
But all other attempts to capture the rest of the needed text are empty, null. Why is that & what am I doing wrong?
Text for regular expression to work on:
<table width="52%" border="1" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" align="center" bgcolor="#999999">Result</td>
</tr>
<tr>
<td width="22%"><strong>Student ID</strong></td>
<td width="78%">13/0003337/99</td>
</tr>
<tr>
<td><strong>Student Name</strong></td>
<td>Alaa Salah Yousuf Omer</td>
</tr>
<tr>
<td><strong>College</strong></td>
<td>Medicine & General Surgery</td>
</tr>
<tr>
<td><strong>Subspecialty</strong></td>
<td>General</td>
</tr>
<tr>
<td><strong>Semester</strong></td>
<td>Fourth</td>
</tr>
<tr>
<td><strong>State</strong></td>
<td>Pass</td>
</tr>
<tr>
<td><strong>Semester's GPA</strong></td>
<td>2.89</td>
</tr>
<tr>
<td><strong>Overall GPA</strong></td>
<td>3.13</td>
</tr>
</table>
My code:
QString resultHTML = "A variable containing the html code written above."
QRegularExpression regex("<td>(.*)</td>", QRegularExpression::MultilineOption);
QRegularExpressionMatch match = regex.match(resultHTML);
// I only get the 1st result logged withing debugger
for(int x = 0; x <= match.capturedLength(); x++)
{
qDebug() << match.captured(x);
}
// This here doesn't get me anything, null!
_studentName = match.captured(2);
_semesterWritten = match.captured(8);
_stateWritten = match.captured(10);
_currentGPA = match.captured(12);
_overallGPA = match.captured(14);