Local $str = FileRead('A1.txt')
Local $sTt = '档案代码|文件名|类型|PRIMARY|INDEX01|INDEX02'
Local $aSS = StringSplit($sTt, '|', 2)
Local $sOut = ''
Local $aSR0 = StringRegExp($str, '(?s)码:.+?(?=档案代|$)', 3) ;分成相同格式的大段
For $i = 0 To UBound($aSR0) - 1
$sOut &= '[档案 ' & $i + 1 & ']' & @CRLF
Local $aSR1 = StringRegExp($aSR0[$i], '(?s).+(?=\v+\=)|.+', 3) ;再分割两部分
If UBound($aSR1) < 2 Then ContinueLoop
Local $aSR2 = StringRegExp($aSR1[0], '(?<!成):(\V+)', 3) ;提取:部分
For $ii = 0 To UBound($aSR2) - 1
$sOut &= $aSS[$ii] & ' = ' & $aSR2[$ii] & @CRLF
Next
Local $aSR3 = StringRegExp($aSR1[1], '(\d+)\h+(\w+\d+)\h+(\H+)\h+(\w)\h+(\d+\.?\d*)\h+(\V+)', 3) ;提取:序号等
If UBound($aSR3) < 6 Then ContinueLoop
Local $x = 1
For $iii = 0 To UBound($aSR3) - 5 Step 6
$sOut &= $x & '序号 = ' & $aSR3[$iii] & @CRLF
$sOut &= $x & '字段代号 = ' & $aSR3[$iii + 1] & @CRLF
$sOut &= $x & '域名 = ' & $aSR3[$iii + 2] & @CRLF
$sOut &= $x & 'TYPE = ' & $aSR3[$iii + 3] & @CRLF
$sOut &= $x & '长度 = ' & $aSR3[$iii + 4] & @CRLF
$sOut &= $x & '备注 = ' & $aSR3[$iii + 5] & @CRLF
$x += 1
Next
$sOut &= @CRLF
Next
Local $sFile = 'testA.ini'
FileDelete($sFile)
FileWrite($sFile, $sOut)
ShellExecute($sFile)
|