- $content = @'
- using System.forms;
- using System;
-
- public class cla
- {
- public string hello()
- {
- return "hello";
- }
- }
- '@
-
- $append = @'
- using System.IO;
- using System.Text;
- '@
-
- $result = $content -replace '^(.|\r|\n)*\n\s*using\s+\w+.*?\n', ('$0' + $append + "`n")
- $filePath = "$HOME\Desktop\a.txt"
- Set-Content -Path $filePath -Value $result
复制代码
|