Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 删除数组中每个值的字符串开头和结尾_Arrays_Powershell_Substring - Fatal编程技术网

Arrays 删除数组中每个值的字符串开头和结尾

Arrays 删除数组中每个值的字符串开头和结尾,arrays,powershell,substring,Arrays,Powershell,Substring,我有一组数据,如下所示: Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"] Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/ad

我有一组数据,如下所示:

Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"]
Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"]
Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"]
Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"]
Resource file d:\path\relevantDtata\WebConfigResource.resx is missing value for key /configuration/addSettings/add[@key="relevantData"]
除少数短部分外,几乎所有这些数据都可以删除

资源文件d:\path\
可以消失

\webconfig.resx缺少key/configuration/addSettings/add[@key=“
也可以。文件
”]
也可以

目前,所有这些数据都存储在
$validationVar
中,我猜我想玩一下子字符串,但我不完全确定到底需要做什么。可能是下面这样的

$validationVar | % $_.substring(15)
所以你可以这样做

$validationVar | % { $_.Substring($_.IndexOf(""""),$_.IndexOf("""]")-$_.IndexOf("="""))}
如果你想要“相关数据”,那就从这里开始吧

所以你可以这样做

$validationVar | % { $_.Substring($_.IndexOf(""""),$_.IndexOf("""]")-$_.IndexOf("="""))}
如果你想要“相关数据”,那就从这里开始吧


我将使用
-用正则表达式替换

$pattern = '^Resource file d:\\path\\(.*?)\\WebConfigResource\.resx is missing value for key /configuration/addSettings/add\[@key="(.*?)"\]'

$validationVar -replace $pattern, '$1$2'

我将使用
-用正则表达式替换

$pattern = '^Resource file d:\\path\\(.*?)\\WebConfigResource\.resx is missing value for key /configuration/addSettings/add\[@key="(.*?)"\]'

$validationVar -replace $pattern, '$1$2'