<! -- Frog recommendation: Use vbs to write a string utility function class. I don't know if it is practical. -->
<%
Class wawa_str 'create a class named Wawa
'*************************************** ******************
'Objective: String utility function. Each method is annotated accordingly. I didn't use a regular expression to determine whether
'Search the boundary of a string, just write a function. If you want to judge the boundary, use/B,
'The political expression of vbs is not easy to use, so I didn't write it. I will try to perfect this class next time.
'And rewrite it to the C # version
'Author: Tianji. Frog Prince
'Variable: wawavalue (private variable)
'Property:
'Method:
'*************************************** ******************
Private wawavalue 'creates an internal private variable
Private sub class_initialize () 'defines class initialization events
End sub
Private sub class_terminate 'sets the terminate event. 'Define the clearing event of the class
End sub
Public property let propertywawa (byval wawa_arg) 'defines a let attribute of the class
Wawavalue = wawa_arg
End Property
Public property get propertywawa () 'defines the get attribute of a class
Propertywawa = wawavalue
End Property
Public Function getfront (byval mainstr, byval searchstr) 'gets the character on the left of the string to be searched
Dim foundoffset
Foundoffset = instr (mainstr, searchstr)
If foundoffset = 1 then
Getfront = ""
End if
Getfront = mid (mainstr, 1, foundoffset-1)
End Function
Public Function getend (byval mainstr, byval searchstr) 'gets the character on the right of the string to be searched
Dim foundoffset
Foundoffset = instr (mainstr, searchstr)
If foundoffset = 1 then
Getend = NULL
End if
Getend = mid (mainstr, Len (searchstr) + 1)
End Function
Public Function insertstring (byval mainstr, byval searchstr, byval insertstr) 'inserts a string before the string to be searched
Dim front, endwawa
Front = getfront (mainstr, searchstr)
Endwawa = getend (mainstr, searchstr)
Insertstring = (front & insertstr & endwawa)
End Function
Public Function deletestring (byval mainstr, byval deletestr) 'deletes the string to be searched
Deletestring = Replace (mainstr, deletestr ,"")
End Function
Public Function replacestring (byval mainstr, byval searchstr, byval replacestr) 'replaces the string to be searched
Dim front, endwawa
Front = getfront (mainstr, searchstr)
Endwawa = getend (mainstr, searchstr)
Replacestring = (front & replacestr & endwawa)
End Function
End Class
Set temp = new wawa_str
Response. Write (temp. getfront ("hellowawa", "Wawa "))
Response. Write ("<br> ")
Response. Write (temp. getend ("wawabyebye", "Wawa "))
Response. Write ("<br> ")
Response. Write (temp. insertstring ("tianwawa", "Wawa", "Cai "))
Response. Write ("<br> ")
Response. Write (temp. deletestring ("wawatiancai", "Wawa "))
Response. Write ("<br> ")
Response. Write (temp. replacestring ("wawatiancai", "Wawa", "hello "))
Response. Write ("<br> ")
'Response. Write ("<br> ")
%>