我想替换文件夹中每个脚本文件中的一些文本,我正在尝试使用此PS代码:
$pattern = '(FROM [a-zA-Z0-9_.]{1,100})(?<replacement_place>[a-zA-Z0-9_.]{1,7})'
Get-ChildItem -Path 'D:\Scripts' -Recurse -Include *.sql | ForEach-Object { (Get-Content $_.fullname) -replace $pattern, 'replace text' | Set-Content $_.fullname }
Run Code Online (Sandbox Code Playgroud)
但我不知道如何保留表达式的第一部分,而只是替换第二部分.知道我该怎么办?谢谢.