回复 afan
afan的确很高明,小弟有一疑问,不知道afan有没有考虑过:
在本提问中,以%cdsroot% ...
xlj310 发表于 2012-8-2 00:36
所以我说“这种规则的字符串用StringMid 来取就行了”
如果不是这种规则当然另当别论,如上面的打乱下。Local $Str = 'path=C:\Windows\system32;%CDSROOT%\tools\pcb\bin;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\bin;%CDSROOT%\tools\bin;C:\usr\local\bin;%CDSROOT%\tools\libutil\bin;%CDSROOT%\tools\fet\bin;%CDSROOT%\tools\specctra\bin;%CDSROOT%\tools\PSpice;%CDSROOT%\tools\PSpice\Library;%CDSROOT%\tools\Capture;C:\Program Files\Windows7Master;%CDSROOT%\OpenAccess\bin\win32\opt;C:\Program Files\SinoVoice\jTTS 5.0 Desktop\Bin'
Local $sRER1 = StringRegExpReplace(StringRegExpReplace($str, '(?i)(?<=\=|;)(?:(?!%CDSROOT%)[^;])+;?', ''), ';?\s*$', '') & ';'
Local $sRER2 = StringRegExpReplace(StringRegExpReplace($str, '^.+?\=|(?i)%CDSROOT%[^;]+;?', ''), ';?\s*$', '')
MsgBox(0, '', '原字符串' & @CRLF & $Str & @CRLF & @CRLF & '替换结果' & @CRLF & $sRER1 & '■分界明示■' & $sRER2)
|