Function ReplaceCondition(byval str)
Dim regEx, Matches, Match, TempStr,Bool
Dim FieldParam,FieldParamArr,ReturnFieldValue,I
on error resume next
Set regEx = New RegExp
regEx.Pattern = "{\$IF\([^\$]*}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
TempStr=str
For Each Match In Matches
FieldParam = Replace(Match.Value,"{$IF(","")
FieldParam =mid(FieldParam,1,(len(FieldParam)-2))
FieldParamArr = Split(FieldParam,"||")
Bool=eval(trim(FieldParamArr(0)))
If Bool="True" Then
ReturnFieldValue=FieldParamArr(1)
Else
ReturnFieldValue=FieldParamArr(2)
End If
TempStr=Replace(TempStr,"{$IF(" &FieldParam &")}",ReturnFieldValue)
Next
ReplaceCondition=TempStr
End Function
可参考 这个函数,替换文本中的{$if(条件||1||2)}这样标签的