I have the following:
$file_input = "cube1_server1_partial.xml"
$CUBEName = [io.path]::GetFileNameWithoutExtension($file_input).ToUpper() -replace "_partial" #strips extension from $file_input
This results in: cube1_server1.
Now I have other file names that came into light, such as:
cube1_server1_full.xml
I want a comprehensive replacement that doesn't necessarily have to hard code the suffix, so instead of -replace "_partial".
It should be something like -replace "_*" from the end of a string.
How can I have a comprehensive replace? maybe with regex?
_and everything following it?$file_input -replace "_[^_]*$"will probably work for most cases.