【发布时间】:2017-06-06 14:42:17
【问题描述】:
考虑这个文件
AppConfig = {
version: '4.0.0',
clientId: "guid",
httpProxy: 'rest',
restUrl: "http://url.contoso.com/v1/",
conferences: ["lync", "hangouts", "webex"], // "lync", "hangouts", "webex"
dataRefreshInterval: 60 //seconds
}
我想用另一个字符串替换单引号内的字符串。我想更改特定属性的值(在我的情况下为 version)。
$content = Get-Content $VersionFile
for($i = 0;$i -lt $content.Count; $i++)
{
if($content[$i] -like "*version:*")
{
$content[$i] = $content[$i] -creplace <replaceWhat>, <replaceWith>
}
}
感谢您以更优雅的方式找到version 的行。
【问题讨论】:
标签: regex powershell