I have a string like “F:\Backup” I need to replace "F:" with nothing. But instead of “F” it could be some other drive, like “D:\Backup”, so I need a wildcard. Something like: $BackupFolder = ‘F:\Backup’ $NewFolder = $BackupFolder -replace "?:" , “”
Since -replace used regex, you will need to pattern match and backslash scape special regex characters (backslash is special here) that need to be handled literally. See regex for explanation