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!
您可能感興趣的文章:- C#刪除最后一個結尾逗號的方法
- js 去除字符串第一位逗號的方法
- JS使用正則去除字符串最后的逗號
- JS去除右邊逗號的簡單方法
- PHP字符過濾函數去除字符串最后一個逗號(rtrim)