A string processing class (Enhanced) (VBScript) in ASP

Source: Internet
Author: User
Tags add array bool check character comparison end return string
vbscript| string |vbscript| string related articles see:

http://www.csdn.net/Develop/read_article.asp?id=22695

This article on the basis of a number of additions, add a few suitable for Chinese web site function to go in, there may be some did not add, there are interested friends can then add a little function on this basis, but don't forget to share!

<%
Class Stringoperations

'****************************************************************************
' @ Feature Description: Swap string for char-type array
' @ parameter Description:-str [string]: a string to convert
' @ return value:-[array] char array
'****************************************************************************
Public Function ToCharArray (ByVal str)
ReDim Chararray (Len (str))
For i = 1 to Len (str)
Chararray (i-1) = Mid (str,i,1)
Next
ToCharArray = Chararray
End Function

'****************************************************************************
' @ Function Description: Converts an array into a string
' @ parameter Description:-arr [Array]: data that needs to be converted
' @ return Value:-[string] string
'****************************************************************************
Public Function arraytostring (ByVal arr)
For i = 0 to UBound (arr)
Strobj = strobj & Arr (i)
Next
arraytostring = Strobj
End Function

'****************************************************************************
' @ Feature Description: Check source string str starts with chars
' @ parameter Description:-str [string]: source string
' @ parameter Description:-chars [string]: Character/string of comparison
' @ 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

'****************************************************************************
' @ Feature Description: Check source string str to end with chars
' @ parameter Description:-str [string]: source string
' @ parameter Description:-chars [string]: Character/string of comparison
' @ 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

'****************************************************************************
' @ Feature Description: Copy n string str
' @ parameter Description:-str [string]: source string
' @ parameter Description:-n [int]: number of copies
"@ return Value:-[string] copied string
'****************************************************************************
Public Function Clone (ByVal str, n)
For i = 1 to n
Value = value & str
Next
Clone = value
End Function

'****************************************************************************
' @ Feature Description: Delete source string The first n characters of 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

'****************************************************************************
' @ Feature Description: Deletes 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

'****************************************************************************
' @ Feature Description: Check character character is English character A-Z or a-Z
' @ parameter Description:-character [char]: Character checked
' @ return value:-[bool] If it is an English character, returns true, False instead
'*******************

[1] [2] [3] Next page



Related Article

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.