Monday, October 3, 2011

PowerShell RegEx

Trying to learn PowerShell by using it to create a NuGet build scripts. In order to parse some code files, I needed to filter a list of strings using a regular expression and capture a match group from the first string matched:
$line = 
    $assembly_info | 
    where {$_ -match 'AssemblyDescription\("(?<1>[^"]*)"\)'} | 
    select -first 1

$matches[1]
Looks almost like a functional language.  Better late to the party than never…

No comments:

Post a Comment