Powershell拆分字符串,带“0”-&引用;和数量

Powershell拆分字符串,带“0”-&引用;和数量,powershell,Powershell,尝试将其拆分为“-”和任意数字, 以便 拆分后的第一部分是abc_test.txt 我在下面试过了 $string = abc_test.txt-1234.xml 将破折号添加到您的-split: $new = $string -Split'(?=\d)' $new[0] $new = $string -Split'(?=-\d)'

尝试将其拆分为“-”和任意数字,
以便 拆分后的第一部分是abc_test.txt

我在下面试过了

$string = abc_test.txt-1234.xml  

将破折号添加到您的
-split

$new = $string -Split'(?=\d)'  
$new[0]
$new = $string -Split'(?=-\d)'