0

这是 PowerShell 代码段:

$regex = ".*[A-Z a-z][ \t]{3,}"
$file = 'C:\temp\log\log.json'

Get-Content $file2) | ForEach-Object {
    $_.replace('{"time": "', "").
    replace($regex, "")

} | Out-File $file

我测试了正则表达式,它可以在 RegExr 网站上运行。

2018-01-10T14:37:08981+00:00 WindowsFeature Storage-Services --> 匹配
2020-01-10T14:37:08997+00:00 WindowsFeature Storage-Services --> 匹配 2020-01-10T14:37: 09059+00:00 WindowsFeature Storage-Services 操作“Get-WindowsFeature”开始:Storage-Services 2018-01-10T14:37:09934+00:00 WindowsFeature Storage-Services 操作“Get-WindowsFeature”成功:Storage-Services

第一次更换已成功完成,但第二次不再更换。

4

0 回答 0