View Single Post
Old 12-17-2007   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: How to work with regular expressions

Jarod wrote:
Quote:

> Hi!
>
> When I do:
>
>
> dir | where { $_.Name -match "\d+" }
>
> It displays names containing numbers.
> What if I want to have just those matched numbers?
>
> So if the file name is : powerShell_01.txt
> I want to have this 01 how to get this?
>
> Later on I'd like to convert it to a number so if it's
> 0001 or 001 or 000001 it's just 1.
>
> and rename files
>
> Thx for help with this.
>
> Jedrzej
>
As Shay posted in an earlier thread:
http://safari.oreilly.com/9780596528...sion_reference

Is definitely a good reference!

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec