asp中怎么替換最后一個逗號為空字符串
舉例 aaa,bbb,ccc,eee, 這個字符串
怎么讓最后一個逗號變沒,其他的不變啊
問題補充:舉例 aaa,bbb,ccc,eee, 這個字符串
怎么讓最后一個逗號變沒,其他的不變啊
如果是aaa,bbb,ccc,eee則不做修改
復制代碼代碼如下:
<%
str="aaa,bbb,ccc,eee,"
if right(str,1)="," then
str=left(str,len(str)-1)
end if
%>
asp Right 函數 可從字符串右邊返回指定數目的字符。
提示:要確定 string 參數中的字符數目,使用 Len 函數
提示:還可以參考下Left函數
語法
Right(string,length)
參數 描述
string
必選項。字符串表達式,其最右邊的字符被返回。
length
必選項。數值表達式,指明要返回的字符數目。如果為 0,返回零長度字符串;如果此數大于或等于 string 參數中的所有字符數目,則返回整個字符串。
實例 1
復制代碼代碼如下:
dim txttxt="This is a beautiful day!"
response.write(Right(txt,11))
輸出:utiful day!
實例 2
復制代碼代碼如下:
dim txttxt="This is a beautiful day!"
response.write(Right(txt,100))
輸出:This is a beautiful day!
實例 3
復制代碼代碼如下:
dim txt,xtxt="This is a beautiful day!"x=Len(txt)
response.write(Right(txt,x))
輸出:This is a beautiful day!