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 函數(shù) 可從字符串右邊返回指定數(shù)目的字符。
提示:要確定 string 參數(shù)中的字符數(shù)目,使用 Len 函數(shù)
提示:還可以參考下Left函數(shù)
語法
Right(string,length)
參數(shù) 描述
string
必選項。字符串表達式,其最右邊的字符被返回。
length
必選項。數(shù)值表達式,指明要返回的字符數(shù)目。如果為 0,返回零長度字符串;如果此數(shù)大于或等于 string 參數(shù)中的所有字符數(shù)目,則返回整個字符串。
實例 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!