本帖最后由 Nsqs 于 2023-8-20 07:48 编辑
ps没那么复杂- $data=gc a.txt
- $s=New-Object 'System.Collections.Generic.List[string][]' 3
- $f='企业'
- for($i=0;$i -lt $data.Count;$i++){
- if($data[$i] -match $f){
- [int]$c=$c%2+1
- $s[$c]=[regex]::Matches($data[$i],"$f.+")
- if($s[1] -ne $s[2]){
- $b=$data[$i-1]
- $data[$i-1]="$($b)`r`n$([regex]::Matches($b,'.+>')) 退出"
- }
- }
- }
- $data=$data -split '\r\n'
- $data[0..($data.Count-2)]>b.txt
复制代码 bat- @echo off&setlocal enabledelayedexpansion
- set n=100
- for /f "delims=" %%1 in (a.txt)do set /a n+=1&call set "#%%n%%=%%1"
- for /f "tokens=1,2,6* delims=#= " %%1 in ('set #')do (
- set /a a=%%1
- set "line=%%3%%4%%5"
- set d=!line:* =!
- set d=!d:~,2!
- if !d!==企业 (
- call set "s!c!=!line!"
- set /a c=c %% 2+1
- if !s1! neq !s2! (
- set /a b=a-1
- call set "#!b!#=%%#!b!:+=%%退出"
- )))
- (for /f "tokens=2* delims==" %%1 in ('set #')do echo %%1)>b1.txt
复制代码
|