How to replace the last comma into an empty string in asp How to replace the last comma into an empty string in asp
For example, aaa, bbb, ccc, eee, this string
How do I make the last comma disappear and the rest remain unchanged?
Question supplement: For example, aaa, bbb, ccc, eee, this string
How do I make the last comma disappear and the rest remain unchanged?
If it is aaa, bbb, ccc, eee, no modification will be made.
Copy the code code 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 side of a 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
grammar
Right(string,length)
Parameter description
string
Required. A string expression whose rightmost character is returned.
length
Required. A numeric expression specifying the number of characters to return. If 0, a zero-length string is returned; if this number is greater than or equal to the number of all characters in the string parameter, the entire string is returned.
Example 1
Copy the code code as follows:
dim txttxt=This is a beautiful day!
response.write(Right(txt,11))
Output: Utiful day!
Example 2
Copy the code code as follows:
dim txttxt=This is a beautiful day!
response.write(Right(txt,100))
Output: This is a beautiful day!
Example 3
Copy the code code as follows:
dim txt,xtxt=This is a beautiful day!x=Len(txt)
response.write(Right(txt,x))
Output: This is a beautiful day!