Table of Contents

PowerShell - Regexp

About

Multilingual Regular Expression Syntax (Pattern) in Powershell

Example

Escape

'`[Hello`]'

Filtering

$VALUE = get-content $META_FILE | Select-String "fmw.*infrastructure" -AllMatches | % { $_.Matches } | %{ $_.Value }
$VALUE = gc $META_FILE | Select-String "fmw_(?<version>.*)_infrastructure" -AllMatches | % { $_.Matches.Groups[1].Value }

Condition

if ($fileName -match '.*zip') {

            $sourceFile="$targetDir\$fileName"
            Write-host "Unzip file", $sourceFile
            echo Expand-Archive $sourceFile -DestinationPath $targetDir -force

}