Powershell & regex, select value in html


I have a added a class tag in a site, specifically to be able to catch it via regex.
This is the html tag which I'm trying to catch

Table class="AntivirusKPI" border=2 cellpadding=4 cellspacing=3>                  
    <TR align=center>
    <TD><B>Latest Engineversion</B></TD>
    <TD><B>Percentage compliant</B></TD>
      <TR><TD align=center>1.1.14405.2</TD><TD class="AvengineVersionCompliancy" bgcolor=lightgreen align=center>99% </TD></TR>

When I try to get it, I do not get any result with regex.

        $URl = 'http://mysite'
        $pattern='<table .*class=\s*"AntivirusKPI"[^>]*>(?:.|\n)+?</table>'
        $webclient = New-Object System.Net.WebClient
        $html = $webclient.DownloadString($url)
        $Regex = [Regex]::Matches($html, $pattern)

Note that I also would like to catch tags with <td class=... <tr class= ... etc.

Please advise.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In your example, you're not getting a match because of case-sensitivity.  Using [regex]::Matches is case-sensitive by default.  You need to use a mode modifier to change that.
$pattern = '(?i)<table .*class=\s*"AntivirusKPI"[^>]*>(?:.|\n)+?</table>'

Open in new window

Sorry, but it's not clear to me what other matches you want and output.  For that, it's best to provide a few input samples and the expected output for each.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.