当前位置: 移动技术网 > IT编程>开发语言>Asp > asp 去除最后一个逗号为空字符串的代码

asp 去除最后一个逗号为空字符串的代码

2017年12月08日  | 移动技术网IT编程  | 我要评论

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! 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网