Skip to content

Instantly share code, notes, and snippets.

@dlwyatt

dlwyatt/demo.ps1 Secret

Last active May 13, 2016 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlwyatt/a48e0afde767ca78880dd97ded947828 to your computer and use it in GitHub Desktop.
Save dlwyatt/a48e0afde767ca78880dd97ded947828 to your computer and use it in GitHub Desktop.
Regex split file name
$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