- $SortLine = {
- $a = @(0)
- $b=$args[0] -split '\n' | %{
- if ($_ -match '^\D*\d+')
- {
- $a[-1] += 1
- $_ -replace '(?<=^\D*)\d+', ($a -join '')
- }
- else { $_ }
- if ($_ -match '^\s*\)') { $a += 0 }
- if ($_ -match '^\s*\(') { $a = $a[0 .. ($a.count - 1 - 1)] }
- }
- $b -join "`n"
- }
-
- function GetTextArea($A,$B,$C,$s=(gc 1.txt) -join "`n"){
- if($A -and $B -and $C){[regex]::replace($s,"(?s)(?<=$A\s+)(?<AB>.*?)(?=\s+$B)",{&$C $args[0].groups['AB'].value})}
- elseif($A -and $C){[regex]::replace($s,"(?s)^(?<A>.*?)(?=\s*$A)",{&$C $args[0].groups['A'].value})}
- elseif($B -and $C){[regex]::replace($s,"(?s)(^.+$B\s+)(?<B>.*)",{$args[0].groups[1].value;&$C $args[0].groups['B'].value})}
- }
复制代码
|