本帖最后由 hnfeng 于 2016-5-9 11:36 编辑
文件中有很多 <ProductKey>........</ProductKey> 这样的文本段,想根据里面的 key 来删掉相应的文本段,但是我使用的表达式会把 第一个 <ProductKey> 到满足条件的 </ProductKey> 之间多个段全删掉。
下面的代码,想要的结果是删掉含有 $a_KeyS 的 文本段(第二段),保留第一段。先谢谢了
local $t_CilxFile="xxxxx " & @CRLF & _
" <ProductKey>" & @CRLF & _
" <KeyDescription>Office15_AccessVL_MAK-Alpha</KeyDescription>" & @CRLF & _
" <KeyId>12345-02162-202-843362-00-2052-7601.0000-0752015</KeyId>" & @CRLF & _
" <KeyType>Mak</KeyType>" & @CRLF & _
" <KeyValue>N3H26-DPD66-4QFF7-DYB3D-KKVT3</KeyValue>" & @CRLF & _
" <LastUpdate xsi:nil=""true"" />" & @CRLF & _
" <LastErrorCode>0</LastErrorCode>" & @CRLF & _
" <RemainingActivations>-1</RemainingActivations>" & @CRLF & _
" <SupportedEditions>ProPlusRetail</SupportedEditions>" & @CRLF & _
" <SupportedSku>064383fa-1538-491c-859b-0ecab169a0ab</SupportedSku>" & @CRLF & _
" <UserRemarks />" & @CRLF & _
" <KeyTypeName>MAK</KeyTypeName>" & @CRLF & _
" </ProductKey>" & @CRLF & _
" <ProductKey>" & @CRLF & _
" <KeyDescription>Office16_AccessVL_MAK</KeyDescription>" & @CRLF & _
" <KeyId>12345-02162-201-810144-00-2052-7601.0000-0752015</KeyId>" & @CRLF & _
" <KeyType>Mak</KeyType>" & @CRLF & _
" <KeyValue>N4CPB-2W4QY-HTRPD-GC6GM-KD43D</KeyValue>" & @CRLF & _
" <LastUpdate xsi:nil=""true"" />" & @CRLF & _
" <LastErrorCode>0</LastErrorCode>" & @CRLF & _
" <RemainingActivations>-1</RemainingActivations>" & @CRLF & _
" <SupportedEditions>ProPlusRetail</SupportedEditions>" & @CRLF & _
" <SupportedSku>064383fa-1538-491c-859b-0ecab169a0ab</SupportedSku>" & @CRLF & _
" <UserRemarks />" & @CRLF & _
" <KeyTypeName>MAK</KeyTypeName>" & @CRLF & _
" </ProductKey> xxxxxxxxxx"
MsgBox(0,0,$t_CilxFile)
Local $a_KeyS="N4CPB-2W4QY-HTRPD-GC6GM-KD43D"
$t_CilxFile=StringRegExpReplace($t_CilxFile, "(?s)<ProductKey>.*?" & $a_KeyS & ".*?</ProductKey>","")
MsgBox(0,0,$t_CilxFile)
|