不客气
替换 Key0 Key1值示例Local $sSource = _
' MODULE' & @CRLF & _
' {' & @CRLF & _
' name = ModuleEnginesFX' & @CRLF & _
' thrustVectorTransformName = thrustTransform' & @CRLF & _
' exhaustDamage = True' & @CRLF & _
' ignitionThreshold = 0.1' & @CRLF & _
' minThrust = 0' & @CRLF & _
' maxThrust = 16' & @CRLF & _
' heatProduction = 150' & @CRLF & _
' fxOffset = 0, 0, 0.01' & @CRLF & _
' localPosition = 0, 0, 0.12' & @CRLF & _
' EngineType = LiquidFuel' & @CRLF & _
' exhaustDamageDistanceOffset = 0.12' & @CRLF & _
' PROPELLANT' & @CRLF & _
' {' & @CRLF & _
' name = LiquidFuel' & @CRLF & _
' ratio = 0.9' & @CRLF & _
' DrawGauge = True' & @CRLF & _
' }' & @CRLF & _
' PROPELLANT' & @CRLF & _
' {' & @CRLF & _
' name = Oxidizer' & @CRLF & _
' ratio = 1.1' & @CRLF & _
' }' & @CRLF & _
' atmosphereCurve' & @CRLF & _
' {' & @CRLF & _
' key = 0 290' & @CRLF & _
' key = 1 275' & @CRLF & _
' key = 7 0.001' & @CRLF & _
' key = X VVVV' & @CRLF & _
' }' & @CRLF & _
' }'
;~ MsgBox(0, '源字符串', $sSource)
Local $v0 = 12345
Local $v1 = 8888.999
Local $sSRERe = StringRegExpReplace($sSource, '(?si)(Key\h*\=\h*0\h+)[\d.]+(.+?\s+Key\h*\=\h*1\h+)[\d.]+', '${1}' & $v0 & '${2}' & $v1)
MsgBox(0, '替换结果', $sSRERe)
|