Clone copy reference
Compareto comparison
Copyto copy objects
Whether the end of endswith matches the specified string
Equals comparison object
Getenumerator get enumeration foreach...
Gethashcode
GetType
Gettypecode type code
Indexof index points to the first string starting with int start
Indexofany any char [] Match
Insert string
The lastindexof index points to the first string ending with int start (from the right to the left)
Lastindexofany any char [] Match
Length, array size
Add string to the left side of padleft to the specified length
Add string to the specified length to the right of padright
Remove remove from string. The array is to delete a string.
Replace
Split split string to string []
Whether startswith matches the specified string
Obtain the substring from int start to int length.
Tochararray to Char []
Tolower lower case
Tostring to string type
Toupper capital
Trim spaces at both ends of trim
Trimend "right" Remove Space
Trimstart "Left" Remove Space
# Region string truncation Function
/// <Summary>
/// String truncation Function
/// If yes, the remaining strings are added with half ellipsis
/// </Summary>
/// <Param name = "inputstring"> string to be truncated </param>
/// <Param name = "len"> truncation length </param>
/// <Returns> truncated string </returns>
Public String cutstring (string inputstring, int Len)
{
Asciiencoding ASCII = new asciiencoding ();
Int templen = 0;
String tempstring = "";
Byte [] S = ASCII. getbytes (inputstring );
For (INT I = 0; I <S. length; I ++)
{
If (INT) s [I] = 63)
{
Templen + = 2;
}
Else
{
Templen + = 1;
}
Try
{
Tempstring + = inputstring. substring (I, 1 );
}
Catch
{
Break;
}
If (templen> Len)
Break;
}
// If yes, add half ellipsis
Byte [] mybyte = system. Text. encoding. Default. getbytes (inputstring );
If (mybyte. length> Len)
{
Tempstring + = "... ";
}
Return tempstring;
}
# Endregion
/// <Summary>
/// Truncate a fixed string
/// If yes, the remaining strings are added with half ellipsis
/// </Summary>
/// <Param name = "inputstring"> string to be truncated </param>
/// <Returns> truncated string </returns>
Public String cutstring (string inputstring, int Len)
{
If (inputstring. length> Len)
{
Return inputstring. substring (0, Len) + "...";
}
Else
{
Return inputstring;
}
Function syntax
Len (string | varname) returns the number of characters in the string or the number of bytes required to store a variable.
Trim trim (string) removes spaces before and after the string
Ltrim (string) removes spaces before the string
Rtrim (string) removes spaces after the string
Mid mid (string, start, length) gets the length string starting from the start character of the string. If the third parameter is omitted, it indicates the string starting from the start character to the end of the string.
Left left (string, length) gets the length string from the left side of the string.
Right right (string, length) gets the length string from the right side of the string.
Lcase (string) converts all uppercase letters in the string to lowercase letters.
Ucase (string) converts all lowercase letters in a string to uppercase letters.
Strcomp (string1, string2 [, compare]) returns the comparison result between the string1 string and the string2 string. If the two strings are the same, 0 is returned. If the two strings are less than 1,-1 is returned, if the value is greater than 1, 1 is returned.
Instr (string1, string2 [, compare]) returns the position where the string1 string first appears in the string2 string.
Split split (string1, delimiter [, Count [, start]) Splits a string into one-dimensional arrays based on delimiter. Delimiter is used to identify the substring boundary. If omitted, use space ("") as the separator.
Count returns the number of substrings.-1 indicates that all substrings are returned.
Start is 1. If it is 0, or the binary comparison is omitted.
Replace Replace (expression, find, replacewith [, compare [, Count [, start]) returns a string, where a specified number of substrings (FIND) replacewith ).
1. Len function example:
The following example uses the Len function to return the number of characters in a string:
Dim mystring
Mystring = Len ("VBScript") ''mystring contains 8.
2. trim, ltrim, and rtrim function examples:
The following example uses the ltrim, rtrim, and trim functions to remove the leading space, trailing space, starting space, and trailing space of a string:
Dim myvar
Myvar = ltrim ("VBScript") ''myvar contains "VBScript ".
Myvar = rtrim ("VBScript") ''myvar contains "VBScript ".
Myvar = trim ("VBScript") ''myvar contains "VBScript ".
3. Mid function example:
The following example uses the mid function to return the six characters starting from the fourth character in the string:
Dim myvar
Myvar = mid ("VB script is fun! ", 4, 6) ''myvar contains" script ".
4. Left function example:
The following example uses the left function to return the three letters on the left of mystring:
Dim mystring, leftstring
Mystring = "VBScript"
Leftstring = left (mystring, 3) ''' leftstring contains "vbs
5. Right function example:
The following example uses the right function to return a specified number of characters from the right side of the string:
Dim anystring, mystr
Anystring = "Hello World" ''defines a string.
Mystr = right (anystring, 1) ''returns" D ".
Mystr = right (anystring, 6) ''returns" world ".
Mystr = right (anystring, 20) ''returns" Hello World ".
6. lcase function example:
The following example uses the lcase function to convert uppercase letters to lowercase letters:
Dim mystring
Dim lcasestring
Mystring = "VBScript"
Lcasestring = lcase (mystring) ''' lcasestring contains "VBScript ".
7. ucase function example:
The following example uses the ucase function to return the string in uppercase:
Dim myword
Myword = ucase ("Hello World") ''returns" Hello World ".
8. strcomp function example:
The following example uses the strcomp function to return the result of string comparison. If the third parameter is 1, text comparison is executed. If the third parameter is 0, binary comparison is executed.
Dim mystr1, mystr2, mycomp
Mystr1 = "ABCD": mystr2 = "ABCD" ''defines the variable.
Mycomp = strcomp (mystr1, mystr2, 1) ''returns 0.
Mycomp = strcomp (mystr1, mystr2, 0) ''returns-1.
Mycomp = strcomp (mystr2, mystr1) ''returns 1.
9. instr example:
The following example uses instr to search for strings:
Dim searchstring, searchchar, Mypos
Searchstring = "xxpxxpxxpxxp "???
Searchchar = "p "??
Mypos = instr (searchstring, searchchar )??? ''Return 9.
Note: The returned result is not the first occurrence of a character string in another string, but the byte position.
10. Split function example:
Dim mystring, myarray, MSG
Mystring = "vbscriptxisxfun! "
Myarray = Split (mystring, "X",-1, 1)
''Myarray (0) contains "VBScript ".
''Myarray (1) contains "is ".
''Myarray (2) contains "fun! ".
Response. Write (myarray (0 ))
11. replace function example:
Replace ("ABCD", "BC", "12") ''To get a12d