SiteScope URL Monitor Regex

507 views Asked by At

I have a web page which has a html code like this below:

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
    <tr>
      <td style="text-align: center; color:#000080; font-weight: bold; font-size: 14pt; background-color:#B0C4DE;" width="100%">AX1</td>
    </tr>
  </tbody>
</table>
<!-- /E/ ftacput3 -->
<div style="color:#000080; font-size:11pt; font-weight:bold;">CPU usage as of: 10:05</div><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td style="text-align:center; color:#D2691E; font-style:italic; font-size:14pt; font-weight:bold;" width="100%" colspan="4">083%</td></tr><tr><td style="background:green; height:25px;" width="70%">&nbsp;</td><td style="background:yellow; height:25px;" width="13%">&nbsp;</td><td style="height:25px;" width="017%">&nbsp;</td></tr></table><br><div><span style="color:#8B4513; font-weight:bold; font-size:11pt;">Recent averages:</span><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#8A2BE2; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 5 minutes </td></tr><tr><td style="text-align:center; color:#8A2BE2; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">094%</td></tr><tr><td style="background:green;" width="70%">&nbsp;</td><td style="background:yellow;" width="20%">&nbsp;</td><td style="background:red;" width="04%">&nbsp;</td><td style="height:10px;" width="006%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#9400D3; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 15 minutes</td></tr><tr><td style="text-align:center; color:#9400D3; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">084%</td></tr><tr><td style="background:green;" width="70%">&nbsp;</td><td style="background:yellow;" width="14%">&nbsp;</td><td style="height:10px;" width="016%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#8B008B; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 30 minutes</td></tr><tr><td style="text-align:center; color:#8B008B; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">076%</td></tr><tr><td style="background:green;" width="70%">&nbsp;</td><td style="background:yellow;" width="06%">&nbsp;</td><td style="height:10px;" width="024%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#9932CC; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 60 minutes</td></tr><tr><td style="text-align:center; color:#9932CC; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">080%</td></tr><tr><td style="background:green;" width="70%">&nbsp;</td><td style="background:yellow;" width="10%">&nbsp;</td><td style="height:10px;" width="020%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td></tr></table></div><br><!-- /B/ ftacput3 -->
<br>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
    <tr>
      <td style="text-align: center; color:#000080; font-weight: bold; font-size: 14pt; background-color:#B0E0E6;" width="100%">AX2</td>
    </tr>
  </tbody>
</table>
<!-- /E/ ftacput3 -->
<div style="color:#000080; font-size:11pt; font-weight:bold;">CPU usage as of: 10:04</div><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td style="text-align:center; color:#D2691E; font-style:italic; font-size:14pt; font-weight:bold;" width="100%" colspan="4">031%</td></tr><tr><td style="background:green; height:25px;" width="31%">&nbsp;</td><td style="height:25px;" width="069%">&nbsp;</td></tr></table><br><div><span style="color:#8B4513; font-weight:bold; font-size:11pt;">Recent averages:</span><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#8A2BE2; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 5 minutes </td></tr><tr><td style="text-align:center; color:#8A2BE2; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">031%</td></tr><tr><td style="background:green;" width="31%">&nbsp;</td><td style="height:10px;" width="069%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#9400D3; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 15 minutes</td></tr><tr><td style="text-align:center; color:#9400D3; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">022%</td></tr><tr><td style="background:green;" width="22%">&nbsp;</td><td style="height:10px;" width="078%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#8B008B; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 30 minutes</td></tr><tr><td style="text-align:center; color:#8B008B; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">021%</td></tr><tr><td style="background:green;" width="21%">&nbsp;</td><td style="height:10px;" width="079%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td><td width="23%"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td style="color:#9932CC; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">Last 60 minutes</td></tr><tr><td style="text-align:center; color:#9932CC; font-style:italic; font-size:10pt; font-weight:bold;" width="100%" colspan="4">037%</td></tr><tr><td style="background:green;" width="37%">&nbsp;</td><td style="height:10px;" width="063%">&nbsp;</td></tr></table></td><td width="02%">&nbsp;</td></tr></table></div><br><!-- /B/ ftacput3 -->
<br>

I need to extract values from the above. In here, the first value is 083 and the second value is 031. I don't know how to highlight the numbers in above, but those will fall in the longest two lines after colspan=4.

When I'm running the following regex expression, I'm able to get the first match, but how to get the 2nd match?

Or, there might be a different way? This can be tested here. http://193.138.212.37/SiteScope/cgi/go.exe/SiteScope

/<td style="text-align:center; color:#D2691E; font-style:italic; font-size:14pt; font-weight:bold;" width="100%" colspan="4">(\d+)/

Thanks,

Koushik

0

There are 0 answers