-
-
Save dlwyatt/a48e0afde767ca78880dd97ded947828 to your computer and use it in GitHub Desktop.
Regex split file name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filename = '06-12-07 Vendor Name.pdf' | |
if ($filename -match '^(?<Date>\d{1,2}[_-]\d{1,2}[_-]\d{1,4})?[_\s-]*(?<VendorName>.+?)\.[^\.]+$') | |
{ | |
$date = $matches['Date'] | |
$vendorName = $matches['VendorName'] | |
Write-Host "Date: '$date', VendorName: '$vendorName'" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment