Frog frog recommendation: a class that uses vbs to write a string Utility Function

Source: Internet
Author: User

<! -- 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> ")
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.