0651デフォルトの名無しさん
2018/04/01(日) 08:53:40.41ID:P1fWuhY2Add-Type -TypeDefinition @"
using System.IO;
using System.Text.RegularExpressions;
public class Hoge {
private static readonly Regex r = new Regex(@"[^\n]*てすと$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.CultureInvariant);
public static void ReplaceLastTest(FileInfo file) {
string s = File.ReadAllText(file.FullName);
s = r.Replace(s.TrimEnd(), string.Empty) + "てすと";
File.WriteAllText(file.FullName, s);
}
}
"@
[Hoge]::ReplaceLastTest((Get-ChildItem ./test.txt))