<%
Class Tool
	dim Content

	Sub Load(Str)
		Content = Str
	End Sub

End Class

Public Function ParseTime(Content, tValue, tSort)
	set regExpTwo = New Regexp
	regExpTwo.IgnoreCase = True
	regExpTwo.Global = True
	regExpTwo.Pattern = "{keyicms:"&tSort&"([\s\S]*?)}"
	set matchesfield = regExpTwo.Execute(Content)
	For Each matchfield in matchesfield
		fieldNameArr = RegExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32))
		fieldNameArr = trim(fieldNameArr)
		m = instr(fieldNameArr,chr(32))
		If  m > 0 then 
			fieldArr = ""
			fieldName = left(fieldNameArr,m - 1)
			fieldArr =	right(fieldNameArr,len(fieldNameArr) - m)
		Else
			fieldName = fieldNameArr
			fieldArr =	""
		End If
		Format = ParseArr(fieldName)("Format")
		If IsNul(Format) Then
			Content = replace(Content, matchfield.value, tValue)
		Else
			Content = replace(Content, matchfield.value, FormatDate(tValue, Format))
		End If
	Next
	ParseTime = Content
End Function

'获取可用标签参数
Public Function ParseArr(Byval attr)
	Set strDictionary = Server.CreateObject("scripting.dictionary")
	Dim attrStr, attrArray, attrDictionary, i, singleAttr, singleAttrKey, singleAttrValue
	attrStr = RegExpReplace(attr, "[\s]+", chr(32))
	attrStr = trim(attrStr)
	attrArray = split(attrStr, chr(32))
	for i = 0 to ubound(attrArray)
		singleAttr = split(attrArray(i), chr(61))
		singleAttrKey = singleAttr(0)
		singleAttrValue = singleAttr(1)
		
		If not strDictionary.Exists(singleAttrKey) then
			strDictionary.add singleAttrKey, singleAttrValue
		Else
			strDictionary(singleAttrKey) = singleAttrValue
		End If
	Next
	set ParseArr = strDictionary
End Function

Public Function RegExpReplace(ContentStr, PatternStr, ReplaceStr)
	Set regExpObj = New Regexp
	regExpObj.Pattern = PatternStr
	RegExpReplace = regExpObj.replace(ContentStr, ReplaceStr)
End Function

Public Function IsNul(str)
	If IsNull(str) or str = "" then IsNul = true Else IsNul = false
End Function

'在str中是否存在findstr
Public Function IsExistStr(Content, findstr)
	If IsNul(Content) or IsNul(findstr) then IsExistStr = false : Exit Function
	If instr(Content, findstr)>0 then IsExistStr = true Else IsExistStr = false
End Function

'是否为数字
Public Function IsNum(str)
	If not IsNul(str) then IsNum = IsNumeric(str) Else IsNum=false
End Function

Public Function ChangeNull(str)
	If IsNull(str) Then
		ChangeNull = ""
	Else
		ChangeNull = str
	End If
End Function

Public Function GetSubStrByFromAndEnd(Str, StartStr, EndStr, OperType)
	Dim location1, location2
	Select Case OperType
		Case "start"
			location1 = instr(Str, StartStr) + len(StartStr) : location2 = len(Str) + 1
		Case "end"
			location1 = 1 : location2=instr(location1,str,endStr)
		Case Else
			location1 = instr(Str, StartStr) + len(StartStr) : location2 = instr(location1, Str, EndStr)
	End Select
	GetSubStrByFromAndEnd = mid(str, location1, location2 - location1) 
End Function
%>