View Single Post
Old 12-17-2007   #3 (permalink)
Keith Hill [MVP]
Guest


 
 

Re: How to work with regular expressions

"Jarod" <Jarod@xxxxxx> wrote in message
news:0FC1C754-9CAE-4F4F-A4F0-F83EE1564E09@xxxxxx
Quote:

> Hi!
>
> When I do:
>
>
> dir | where { $_.Name -match "\d+" }
dir | %{if ($_.name -match '(\d+)') { $matches[1] }}

Any match with the operator -match updates a global called $matches. Any
capture groups (named or unnamed) are created as properties on this object.
$matches[1] would be the first unnamed capture group.

--
Keith



My System SpecsSystem Spec