How to replace the last comma in ASP with a Null String
For example, AAA, BBB, CCC, eee.
How can I leave the last comma unchanged?
Example: AAA, BBB, CCC, eee.
How can I leave the last comma unchanged?
Aaa, BBB, CCC, and Eee are not modified.
CopyCode The Code is as follows: <%
STR = "AAA, BBB, CCC, eee ,"
If right (STR, 1) = "," then
STR = left (STR, Len (STR)-1)
End if
%>
The ASP right function returns a specified number of characters from the right of the string.
Tip: to determine the number of characters in the string parameter, use the Len function.
Tip: You can also refer to the left function.
Syntax
Right (string, length)
Parameter description
String
Required. String expression. the rightmost character is returned.
Length
Required. A numeric expression that specifies the number of characters to return. If the value is 0, a zero-length string is returned. If the value is greater than or equal to the number of all characters in the string parameter, the entire string is returned.
Instance 1Copy codeThe Code is as follows: dim txttxt = "this is a beautiful day! "
Response. Write (right (txt, 11 ))
Output: utiful day!
Instance 2Copy codeThe Code is as follows: dim txttxt = "this is a beautiful day! "
Response. Write (right (txt, 100 ))
Output: This is a beautiful day!
Instance 3Copy codeThe Code is as follows: dim txt, xtxt = "this is a beautiful day! "X = Len (txt)
Response. Write (right (txt, x ))
Output: This is a beautiful day!