So what I have now will (below) will search for XX-##-# and force it to XX-##-#0000.
How can I do this to return XX-##-0000#?
Is there a way to force 5 digits at the end, filling preceding 0s, to cover the other possibilities (XX-##-##, XX-##-###, XX-##-####)? As opposed to copying this 4 times, slightly adjusting for each.
$Pattern1 = '[a-zA-Z][a-zA-Z]-[0-9][0-9]-[0-9]'
Get-ChildItem 'C:\path\to\file\*.txt' -Recurse | ForEach {
(Get-Content $_ |
ForEach { $_ -replace $Pattern1, ('$1'+'0000')}) |
Set-Content $_
}
Thanks.
EDIT: I would like to do the following
Search Replacement
XX-##-# XX-##-0000#
XX-##-## XX-##-000##
XX-##-### XX-##-00###
XX-##-#### XX-##-0####