The largest cool station demonstration center in China!
This class is used to process string, which is written by foreigners. I add the function and parameters inside to explain
How to use:
====================================
<!-#Include file = StringOperations.asp->
<%
Dim Str
set str = New Stringoperations
Test = Str.tocharray (Check this out)
response.write <strong> Str.tocharray </strong>:
for i = 0 to ubound (test)
response.write test (i) &
next
response.write <br> <br>
test1 = stra.arraytring (test)
response.write <strong> Str.arraytring </strong>: & test1
response.write <br> <br>
response.write <strong> Str.startswith </strong>: & Str.startswith (test1, ch)
response.write <br> <br>
response.write <strong> Str.endwith </strong>: & strongswith (test1, out)
response.write <br> <br>
response.write <strong> Str.clone </strong>: & Str.clone (ABC, 10)
response.write <br> <br>
response.write <strong> Str.trimStart </strong>: & Strimstart (test1, 3)
response.write <br> <br>
response.write <strong> Str.trimend </strong>: & strongr.trimend (test1, 2)
response.write <br> <br>
response.write <strong> Str.swapcase </strong>: & Str.swapcase (hihihi) (hihihi)
response.write <br> <br>
response.write <strong> Str.isalphabetic </strong>: & Str.isalphbetic (!)
response.write <br> <br>
response.write <strong> Str.Capitalize </strong>: & Str.Capitalize (Clara Fehler)
set str = nothing
%>
=============== stringoperations.asp================
<%
Class StringOperations
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: replace the string to the Char type array
'' @Parameter description: -dr [string]: string that needs to be converted
'' @Return Value: - [Array] Char type array
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public functions
Redim Chararray (Len (STR))
for i = 1 to len (STR)
chararray (i-1) = mid (str, i, 1)
next
ToCharRray = Chararray
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: convert a array into a string
'' @Parameter Description: -Arr [Array]: Data needed to be converted
'' @Return Value: - [String] string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public functions (Byval ARR)
for i = 0 to ubound (ARR)
Strobj = Strobj & ARR (i)
next
arraytring = Strobj
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: Check whether the source string Str starts with Chars
'' @Parameter description: -str [string]: source string
'' @Parameter description: -CHARS [String]: Comparison character/string
'' @Return Value: - [BOOL]
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function startswith (byval str, chars)
if left (str, len (chars)) = chars then
startswith = true
else
startswith = false
end if
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: Check whether the source string STR ends with chars
'' @Parameter description: -str [string]: source string
'' @Parameter description: -CHARS [String]: Comparison character/string
'' @Return Value: - [BOOL]
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function endswith (byval str, chars)
if right (str, len (chars)) = chars then
endswith = true
else
endswith = false
end if
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: Copy n string str
'' @Parameter description: -str [string]: source string
'' @Parameter description: -N [int]: Number of replicas
'' @Return Value: - [String] Copy string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function clone (byval str, n)
for i = 1 to n
Value = Value & Str
next
clone = value
end function
'***********************************************************************************************************************************************************************************************************************************************************************, ***************
|||The largest website source resource download station,
*****************'' @Function description: Delete the front n characters of the source string STR
'' @Parameter description: -str [string]: source string
'' @Parameter description: -N [int]: Number of characters deleted
'' @Return Value: - [String] Deleted string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function trimstart (byval str, n)
Value = MID (STR, N+1)
trimstart = value
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: Delete the last n string of the source string STR
'' @Parameter description: -str [string]: source string
'' @Parameter description: -N [int]: Number of characters deleted
'' @Return Value: - [String] Deleted string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function trimend (Byval Str, N)
Value = Left (STR, Len (STR) -n))
trimend = value
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: Check whether the character Character is English character AZ or AZ
'' @Parameter description: -Character [Char]: The character checked
'' @Return Value: - [BOOL] If it is an English character, return true, otherwise False
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public functions
ASCIIVALUE = CINT (ASC (Character))
if (65 <= ASCIIVALUE and ASCIIVALUE <= 90) or (97 <= ASCIIVALUE and ASCIIVALUE <= 122) Then
Isalphabetic = TRUE
else
Isalphabetic = false
end if
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function Note: Perform a lower case conversion of the Str string
'' @Parameter description: -str [string]: source string
'' @Return Value: - [String] The converted string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function swapcase (STR)
for i = 1 to len (STR)
Current = MID (STR, I, 1)
if isalphabetic (Current) then
High = asc (ucase (current))
Low = ASC (LCASE (Current))
SUM = HIGH + LOW
Return = Return & Chr (Sum-ASC (Current))
else
Return = Return & CURRENT
end if
next
swapcase = Return
end function
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
'' @Function description: convert the first letter of each word in the source string STR into uppercase
'' @Parameter description: -str [string]: source string
'' @Return Value: - [String] The converted string
'***********************************************************************************************************************************************************************************************************************************************************************, *************************************
Public function capitalize (STR)
Words = Split (str,)
for i = 0 to ubound (words)
if not i = 0 then
TMP =
end if
TMP = TMP & UCASE (left (Words (I), 1)) & Right (Words (I), Len (Words (i))-1)
words (i) = TMP
next
capitalize = Arraytring (Words)
end function
end class
%>