本帖最后由 WHY 于 2020-12-8 10:30 编辑
1.提取 a.txt 文本 Write-Output "之间的字符"到 b.txt- $arr = (gc a.txt -ReadCount 0) -match 'Write-Output +"(?>[^"]+)"' | forEach {$_.Split('"')[1]};
- sc b.txt -Value $arr;
复制代码 2.文本 b.txt 翻译后保存到 c.txt
3.文本 c.txt 替换 a.txt 对应文字,写入 d.txt- $global:n = 0;
- $arr = (gc c.txt -ReadCount 0) -notmatch '^\s*$';
- $str = (gc a.txt -ReadCount 0) -join "`r`n";
- $str = [regex]::Replace($str, '(?<=(?i)Write-Output +")(?>[^"]+)(?=")', {$arr[$global:n++]});
- sc d.txt -Value $str;
复制代码
|