$Str = _
'==================================================' & @CRLF & _
'编 号=03' & @CRLF & _
'用户名=张三' & @CRLF & _
'密 码=123456' & @CRLF & _
'==================================================' & @CRLF & _
'' & @CRLF & _
'==================================================' & @CRLF & _
'编 号=03' & @CRLF & _
'用户名=李四' & @CRLF & _
'密 码=654321' & @CRLF & _
'==================================================' & @CRLF & _
'' & @CRLF & _
'==================================================' & @CRLF & _
'编 号=03' & @CRLF & _
'用户名=王五' & @CRLF & _
'密 码=123' & @CRLF & _
'=================================================='
MsgBox(0, '原字符串', $Str)
Local $i = 1, $bj
While 1
If Not $bj Then
$Str = StringRegExpReplace($Str, '==+', '[' & StringFormat('%03d', $i) & ']', 1)
$bj = True
$i += 1
Else
$Str = StringRegExpReplace($Str, '==+(\r\n|$)', '', 1)
$bj = False
EndIf
If @extended = 0 Then ExitLoop
WEnd
MsgBox(0, '替换后', $Str)
|