asp中怎么替換最后一個(gè)逗號(hào)為空字符串
舉例 aaa,bbb,ccc,eee, 這個(gè)字符串
怎么讓最后一個(gè)逗號(hào)變沒(méi),其他的不變啊
問(wèn)題補(bǔ)充:舉例 aaa,bbb,ccc,eee, 這個(gè)字符串
怎么讓最后一個(gè)逗號(hào)變沒(méi),其他的不變啊
如果是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ù)
語(yǔ)法
Right(string,length)
參數(shù) 描述
string
必選項(xiàng)。字符串表達(dá)式,其最右邊的字符被返回。
length
必選項(xiàng)。數(shù)值表達(dá)式,指明要返回的字符數(shù)目。如果為 0,返回零長(zhǎng)度字符串;如果此數(shù)大于或等于 string 參數(shù)中的所有字符數(shù)目,則返回整個(gè)字符串。
實(shí)例 1
dim txttxt="This is a beautiful day!"
response.write(Right(txt,11))
輸出:utiful day!
實(shí)例 2
dim txttxt="This is a beautiful day!"
response.write(Right(txt,100))
輸出:This is a beautiful day!
實(shí)例 3
dim txt,xtxt="This is a beautiful day!"x=Len(txt)
response.write(Right(txt,x))
輸出:This is a beautiful day!
您可能感興趣的文章:- C#刪除最后一個(gè)結(jié)尾逗號(hào)的方法
- js 去除字符串第一位逗號(hào)的方法
- JS使用正則去除字符串最后的逗號(hào)
- JS去除右邊逗號(hào)的簡(jiǎn)單方法
- PHP字符過(guò)濾函數(shù)去除字符串最后一個(gè)逗號(hào)(rtrim)