Powershell regex for string between two special characters
问题 A file name as below $inpFiledev = "abc_XYZ.bak" I need only XYZ in a variable to do a compare with other file name. i tried below: [String]$findev = [regex]::match($inpFiledev ,'_*.').Value Write-Host $findev 回答1: Asterisks in regex don't behave in the same way as they do in filesystem listing commands. As it stands your regex is looking for underscore, repeated zero or more times, followed by any character (represented in regex by a period). So the regex finds zero underscores right at the