本帖最后由 WHY 于 2019-1-3 09:29 编辑
- $str = [IO.File]::ReadAllText('1.txt', [Text.Encoding]::Default);
- $arr = $str -replace '(?m)^\s+|\r\n' -split '(?<=[。,])(?!$)';
- $str = (get-Random $arr -Count $arr.Count) -join '' -replace ',$', '。';
- $str = [regex]::Replace($str, '。(?!$)', { If((get-Random) % 5){'。'}Else{"。`r`n "} });
- [IO.File]::WriteAllText('2.txt', ' ' + $str, [Text.Encoding]::Default)
复制代码
|