从字符串末尾删除逗号 [英] Remove commas from end of string

查看:134
本文介绍了从字符串末尾删除逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP / VB我需要从字段末尾删除不需要的逗号

将在数组中使用。该字段中的项目是以逗号分隔的逗号,因此我不想删除它们,只是结束它们,

可能是最多5个不需要的地方逗号。


有什么想法吗?


干杯,


史蒂夫

Using ASP/VB I need to remove unwanted commas from the end of a field
that will be use in an array. There are items in the field that are
comma separated, so I don''t want to remove them, just the end ones,
could be anywhere up to 5 unwanted commas.

Any ideas?

Cheers,

Steve

推荐答案

Dooza写道:
Dooza wrote:

使用ASP / VB我需要从字段末尾删除不需要的逗号

将在数组中使用。该字段中的项目是以逗号分隔的逗号,因此我不想删除它们,只是结束它们,

可能是最多5个不需要的地方逗号。


有什么想法吗?


干杯,


Steve
Using ASP/VB I need to remove unwanted commas from the end of a field
that will be use in an array. There are items in the field that are
comma separated, so I don''t want to remove them, just the end ones,
could be anywhere up to 5 unwanted commas.

Any ideas?

Cheers,

Steve



如果有人需要这样做,我发现这是:


函数ctrim(str,trimstr)

修剪时(左(str,1))= trimstr

str = trim(右(str,Len(str)-1))

wend

while trim(右(str,1))= trimstr

str = trim(左(str,Len(str)-1))

wend

ctrim = str

结束功能


<%

str =" ,, a ,b,c,

Response.write ctrim(str,",")

%>


Steve

In case anyone needs to do this, here is what I found:

function ctrim(str,trimstr)
while trim(left(str,1))=trimstr
str=trim(right(str,Len(str)-1))
wend
while trim(right(str,1))=trimstr
str=trim(Left(str,Len(str)-1))
wend
ctrim=str
end function

<%
str=",,a,b,c,"
Response.write ctrim(str,",")
%>

Steve


Dooza于2008年1月8日在microsoft.public.inetserver.asp.general上写道:
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:

使用ASP / VB
Using ASP/VB



我想ASP / VBS?

I suppose ASP/VBS?


我需要从字段末尾删除不需要的逗号

将在数组中使用。该字段中的项目是以逗号分隔的逗号,因此我不想删除它们,只是结束它们,

可能是最多5个不需要的地方逗号。
I need to remove unwanted commas from the end of a field
that will be use in an array. There are items in the field that are
comma separated, so I don''t want to remove them, just the end ones,
could be anywhere up to 5 unwanted commas.



<%''vbscript

dim s

s =" blah,blah,blah ,, ,,,"

response.write endCommasAway(s)

%>


< script language ='' jscript''runat =''server''>

函数endCommasAway(x){return x.replace(/,*

<% '' vbscript
dim s
s = "blah, blah, blah,,,,,"
response.write endCommasAway(s)
%>

<script language=''jscript'' runat=''server''>
function endCommasAway(x){ return x.replace(/,*


/,'''' ); };

< / script>

-

Evertjan。

荷兰。

(请将我的电子邮件地址中的x'变为点数)
/,''''); };
</script>

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


这篇关于从字符串末尾删除逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆