本帖最后由 ivor 于 2019-5-23 19:33 编辑
- [regex]::Matches((Get-Content .\成绩表.txt -Raw -Encoding UTF8),'\[[\s\S]+?(?=\[|$)') | %{
- $name = [regex]::Matches($_,"\[.*\]")
- $score = [regex]::Matches($_,".*=.*")
- foreach($s in $score){
- $fileName = [regex]::Matches($s,".+(?==)")
- Write-Output $name.Value >> $fileName".txt"
- Write-Output $s.Value >>$fileName".txt"
- }
-
- }
复制代码 感谢amwfjhh:指正,已修复“最后一个人的数据”的问题 |