纯体力活……
Local $sSource = _
'<add key="ConnectionString" value="server=localhost;database=cd;User ID=sa;password=Test2017" />' & @CRLF & _
' <add key="ConnectionString2" value="server=localhost;database=dz;User ID=sa;password=Test2017" />' & @CRLF & _
' <add key="AciveTimeout" value="30" />' & @CRLF & _
' <add key="RefreshTimeout" value="20" />' & @CRLF & _
' <add key="currentVersion" value="Version2.1 20120408" />' & @CRLF & _
' <add key="lifeCycle" value="30" /> ' & @CRLF & _
' <add key="validPw" value="03FB6D2706C1DB1771D3886267"/> ' & @CRLF & _
'<add key="plateImgPath" value="http:\\192.168.1.13\videos\"/>' & @CRLF & _
'<add key="MJDataBaseConnectString" value="server=192.168.1.134;database=MJDataBase;User ID=sa;password=Test2017" />'
;~ MsgBox(0, '源字符串', $sSource)
Local $sR1 = '192.168.5.12'
Local $sR2 = 'kxp'
Local $sR3 = 'admin'
Local $sR4 = 'admin2017'
Local $sR5 = '03FB6D2706C1DB1771D388T453'
Local $sR6 = '192.168.5.13'
Local $sR7 = 'mjxt'
Local $sR8 = 'mj'
Local $sR9 = 'admin2017'
Local $sSRERe = StringRegExpReplace($sSource, '("ConnectionString" value="server=)([^;]+)(;database=)([^;]+)(;User ID=)([^;]+)(;password=)([^"]+)("[\S\s]+?validPw" value=")([^"]+)("/>[\S\s]+?"server=)([^;]+)(;database=)([^;]+)(;User ID=)([^;]+)(;password=)([^"]+)(?=")', '${1}' & $sR1 & '${3}' & $sR2 & '${5}' & $sR3 & '${7}' & $sR4 & '${9}' & $sR5 & '${11}' & $sR6 & '${13}' & $sR7 & '${15}' & $sR8 & '${17}' & $sR9)
MsgBox(0, '替换结果', $sSRERe)
|