所以我正在尝试使用正则表达式的字符串
Successfully created package 'C:\Users\mhopper\Documents\CreateNugetPackage\AjaxControlToolkit.3.5.50401.nupkg'
我试图做一个正则表达式来提取“成功”和“C:\ Users \ mhopper \ Documents \ CreateNugetPackage \ AjaxControlToolkit.3.5.50401.nupkg”
我没用过很多正则表达式,但是我做的却没用,到目前为止
'.*(Successfully\.*\C\D+).*', '$1'
最佳答案
正则表达式:
^(\S*)\s.*'(.*)'$
https://regex101.com/r/eC7vX1/1
电源 shell :
$line = "Successfully created package 'C:\Users\mhopper\Documents\CreateNugetPackage\AjaxControlToolkit.3.5.50401.nupkg'"
$values = $line -split "^(\S*)\s.*'(.*)'$"
$status = $values[1]
$path = $values[2]
("status:{0}\npath:{1}" -f $status,$path)
关于regex - 正则表达式从字符串中提取某些位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27696546/