To modify a record:
1, add extension function, 2006-12-3
<%
'******************************
' Class Name: Tagengine
' Name: Tag engine
' Date: 2006-11-29
' Author: West Building Cold Month
' URL: www.xilou.net | www.chinaCMS.org
' Description: Only extract tag function, no parse tag function
' Copyright: Reprint, please note the name of the source, the author
'******************************
' Last modified: 2006-12-3
' Number of changes: 3
' Change Note: Modify the regular to make the match more accurate
' Current version: v1.1.3
'******************************
Class Tagengine
Private regEx ' Regular object
' Define label rules
Private Tagbegin
Private Tagend
Private Blockbegin_begin
Private Blockbegin_end
Private Blockend_begin
Private Blockend_end
'//initialization
Private Sub Class_Initialize ()
' Initialize label rules
Tagbegin= "{"
Tagend= "}"
blockbegin_begin= "<block:"
Blockbegin_end = ">"
Blockend_begin = "</block:"
Blockend_end = ">"
' Initialize the regular object
Set regex=new REGEXP
Regex.ignorecase=true ' case-insensitive
Regex.global=true ' Global match
End Sub
Private Sub Class_Terminate ()
' Release object
If IsObject (regEx) Then Set regex=nothing
End Sub
' Method: Resetpattern ()
Parameters
' Return: no return value
' Function: Reset label rules
Public Sub Resetpattern (tagbegin,tagend,_
Blockbegin_begin,_
Blockbegin_end,_
Blockend_begin,_
Blockend_end _
)
Tagbegin=tagbegin
Tagend=tagend
Blockbegin_begin=blockbegin_begin
Blockbegin_end =blockbegin_end
Blockend_begin =blockend_begin
Blockend_end =blockend_end
End Sub
' Method: Getblocks (Temp,blockname)
' Parameter: Temp, to match the content; blockname, block flag name
' Return: Return collection object (matches)
' function: Get block Tag Collection
Public Function getblocks (temp,blockname)
Dim pattern
Pattern= "(" &blockbegin_begin& "[]*" &blockname& "\b[\w\w]*?") &blockbegin_end
pattern=pattern& ") ([\w\w]*?)" &blockend_begin& "[\n\r]*" &blockname& "[]*" &blockend_end
' Response.Write pattern
Regex.pattern=pattern
Set Getblocks=regex.execute (temp) ' Returns a matching collection
End Function
' Method: Getblockbyatt (Temp,attributename,attributevalue)
' Parameter: Temp, content to match; attributename, attribute name; AttributeValue, property value
' Return: Return collection object (matches)
' Function: To obtain a conforming block set based on the value of an attribute in a block label
Public Function Getblockbyatt (temp,attributename,attributevalue)
Dim pattern
Pattern= "(" &blockbegin_begin& "[\w\w]*?[\n\r]+" &attributename
pattern=pattern& "[]*=[]*\" &CHR (R) &attributevalue& "&CHR" (%) & "[\n\r]*[\w\w]*?"
Pattern=pattern&blockbegin_end
pattern=pattern& ") ([\w\w]*?)" &blockend_begin& "[\w\w]*?" &blockend_end
' Response.Write pattern
Regex.pattern=pattern
Set Getblockbyatt=regex.execute (temp) ' Returns a matching collection
End Function
' Method: Getattvalue (Temp,attributename)
' Parameter: Temp, the content to match; AttributeName, property name
' Return: Return collection object (matches)
' Function: Gets the property value within the block label
Public Function Getattvalue (temp,attributename)
Dim pattern
Pattern= "[\n\r]+" &attributename& "[]*=[]*\" &CHR (+) & "([^\f\n\r\t\v\" &CHR (+) & "]*?) \ "&CHR (34)
' Response.Write pattern
Regex.pattern=pattern
Set Getattvalue=regex.execute (temp)
End Function
' Method: Parsetag (Temp,tagname,tagvalue)
' Parameter: Temp, content to match; attributename, attribute name; AttributeValue, property value
' Return: Returns the replaced string
' Function: replace simple label
Public Function Parsetag (temp,tagname,tagvalue)
Dim pattern
' pattern=tagbegin& ' []* ' &tagname& ' []* '] &tagend
Pattern=tagbegin&tagname&tagend
Regex.pattern=pattern
Parsetag=regex.replace (Temp,tagvalue)
End Function
' Method: Clearblocks (temp)
' Parameter: Temp, content to match
' Return: Returns the purged string
' Function: Clear all block labels
Public Function clearblocks (temp)
Dim pattern
pattern=blockbegin_begin& "[\w\w]*?" &blockbegin_end& "[\w\w]*?"
pattern=pattern&blockend_begin& "[\w\w]*?" &blockend_end
Regex.pattern=pattern
Clearblocks=regex.replace (temp, "")
End Function
' Method: Cleartags (temp)
' Parameter: Temp, content to match
' Return: Returns the purged string
' Function: Clear all single label
Public Function cleartags (temp)
Dim pattern
pattern=tagbegin& "[^\f\n\r\t\v]*?" &tagend
Regex.pattern=pattern
Cleartags=regex.replace (temp, "")
End Function
' Method: ShowError (Errdes)
' Parameters: Errdes, error description
' Return: None
' Function: Display error
Public Sub ShowError (errdes)
Dim Errinfo,cssstyle
Cssstyle= "style=" &CHR (34)
cssstyle=cssstyle& "Font:bold 12px 150%, ' Arial '; border:1px solid #CC3366;"
cssstyle=cssstyle& "Width:50%;color: #990066;p adding:2px;" &CHR (34)
errinfo=vbcrlf& "<ul" &cssstyle& "><li>" &errdes& "</li></ul>" & vbCrLf
Response.Write Errinfo
End Sub
' ****************** standard function End ****************
' The following is a custom extension feature
' Method: Ext_getsimpleblocks (Temp,blockname)
' Parameter: Temp, to match the content; blockname, block flag name
' Return: Return collection object (matches)
' function: Get a simple block tag collection
"Example: <block:new id=" "loop=" "/>
Public Function ext_getsimpleblocks (temp,blockname)
Dim pattern
Dim Blockbegin,blockend
' Redefine the label rule
blockbegin= "<block:"
Blockend = "/>"
pattern=blockbegin& "[]*" &blockname& "\b[\w\w]*"? &blockend
Regex.pattern=pattern
Set Ext_getsimpleblocks=regex.execute (temp)
End Function
' ****************** standard function End ****************
' The following is a custom extension feature
' Method: Ext_getsimpleblocks (Temp,blockname)
' Parameter: Temp, to match the content; blockname, block flag name
' Return: Return collection object (matches)
' function: Get a simple block tag collection
"Example: <block:new id=" "loop=" "/>
Public Function ext_getsimpleblocks (temp,blockname)
Dim pattern
Dim Blockbegin,blockend
' Redefine the label rule
blockbegin= "<block:"
Blockend = "/>"
pattern=blockbegin& "[]*" &blockname& "\b[\w\w]*"? &blockend
Regex.pattern=pattern
Set Ext_getsimpleblocks=regex.execute (temp)
End Function
' Method: Ext_gettext (PATH)
' Parameter: path, relative or absolute path of text to read
' Back: Return text content
' Function: Read file
' Example: C=ext_gettext ("tpl.htm")
Public Function ext_gettext (path)
Dim Fso,f,text
On Error Resume Next
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f=fso.opentextfile (PATH)
Text=f.readall
If ERR Then
Err.Clear
ShowError "Error reading file ..."
If IsObject (FSO) Then Set fso=nothing
Exit Function
End If
If IsObject (FSO) Then Set fso=nothing
Ext_gettext=text
End Function
' Method: Ext_getincludefile (temp)
' Parameter: Temp, content to match
' Return: Return collection object (matches)
' Function: Parsing <!--#include file= "tpl.html"--> block
' Example: Ext_getincludefile (temp) (0). Submatches (0), returns the first matching filename
Public Function ext_getincludefile (temp)
Dim pattern
Dim Blockbegin,blockend
' Redefine the label rule
Blockbegin= "<!--#include"
Blockend = "-->"
pattern=blockbegin& "[]*file[]*=[]*\" "([\w\w]*?) \ "[]*" &blockend
Regex.pattern=pattern
Set Ext_getincludefile=regex.execute (temp)
End Function
End Class
%>