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

时间:2010-06-09 19:18:00 

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="aspxhome.com:This is a beautiful day!" 
response.write(Right(txt,100)) 

输出:aspxhome.com: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!

标签:字符串,asp,right函数
0
投稿

猜你喜欢

  • VSCode远程连接服务器报错:Could not establish connection to

    2023-10-03 03:02:17
  • python windows安装cuda+cudnn+pytorch教程

    2023-02-04 04:35:02
  • 用什么库写 Python 命令行程序(示例代码详解)

    2023-01-01 09:35:10
  • python连接字符串的方法小结

    2023-12-29 16:24:49
  • JavaScript 获取客户端计算机硬件及系统信息

    2009-01-13 17:59:00
  • Tensorflow深度学习使用CNN分类英文文本

    2021-01-02 08:07:56
  • python中翻译功能translate模块实现方法

    2021-05-09 17:02:33
  • SQL Server 2005改进后的几个实用新特性

    2008-05-07 19:16:00
  • python向已存在的excel中新增表,不覆盖原数据的实例

    2022-04-26 15:16:51
  • 一篇文章教你用Python绘画一个太阳系

    2022-12-16 14:43:16
  • css网页下拉菜单制作方法(2):初步实现

    2007-02-03 11:39:00
  • 一个很棒的js图片代码

    2009-12-17 18:36:00
  • JS中FormData类实现文件上传

    2024-04-10 10:50:10
  • 对python3 sort sorted 函数的应用详解

    2022-08-01 23:44:45
  • Go语言基础go fmt命令使用示例详解

    2024-01-31 11:37:34
  • SQL 字母数字混合型字段 按里面的数字排序

    2010-04-23 18:18:00
  • JS出现失效的情况总结

    2023-08-24 00:44:42
  • python3.6生成器yield用法实例分析

    2022-11-22 00:07:05
  • Autopep8的使用(python自动编排工具)

    2022-07-04 11:10:47
  • python中的字符串切割 maxsplit

    2022-04-16 14:35:35
  • asp之家 网络编程 m.aspxhome.com