Its funny, this is actually very close to the first portion of my Powershell script. Does this allow me to call and count the matches in an individual capture group? To do this in Powershell (sorry to bring this here but I find it easier to explain code in code form)
$output = ./bpdbjobs $Results = @() $ColumnName = @() foreach ($match in $OUTPUT) { $matches = $null $match -match "(?<jobID>\d+)?\s+(?<Type>(\b[^\d\W]+\b)|(\b[^\d\W]+ +\b\s+\b[^\d\W]+\b))?\s+(?<State>(Done)|(Active)|(\w+\w+`-\w`-+))?\s+( +?<Status>\d+)?\s+(?<Policy>(\w+)|(\w+`_\w+)|(\w+`_\w+`_\w+))?\s+(?<Sc +hedule>(\b[^\d\W]+\b\-\b[^\d\W]+\b)|(\-)|(\b[^\d\W]+\b))?\s+(?<Client +>(\w+\.\w+\.\w+)|(\w+))?\s+(?<Dest_Media_Svr>(\w+\.\w+\.\w+)|(\w+))?\ +s+(?<Active_PID>\d+)?\s+(?<FATPipe>\b[^\d\W]+\b)?" $Results+=$matches } foreach ($result in $results) { $Object = New-Object psobject -Property @{ JobID = $Result.jobID Type = $Result.Type State = $Result.State Status = $Result.Status Policy = $Result.Policy Schedule = $Result.Schedule Client = $Result.Client Dest_media_svr = $Result.dest_media_svr Active_PID = $Result.Active_PID FATPipe = $Result.FATPipe } $ColumnName += $Object }
Powershell already understands that $Result.jobID is referring to the jobID capture group. All this does is put the capture group and results of said capture into an object which I can put into a variable and use any time using the below code as an example
$Successful = ($ColumnName | where {$_.Status -eq "0"}).count
This creates a variable which is formed out of the previous codes variable, it then pulls out only the matches in the Status column ($_.Status) and counts the ones that match the value 0.

In reply to Re^2: Turning regex capture group variables into arrays, then counting the number of objects in the array by Djay
in thread Turning regex capture group variables into arrays, then counting the number of objects in the array by Djay

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.