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

(编辑:jimmy 日期: 2024/9/22 浏览:2)

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! 

一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。