473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Remove commas from end of string

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
Jan 8 '08 #1
11 10397
Dooza wrote:
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
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
Jan 8 '08 #2
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
Using ASP/VB
I suppose ASP/VBS?
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'>
function endCommasAway(x){ return x.replace(/,*$/,''); };
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 8 '08 #3
Evertjan. wrote:
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
>Using ASP/VB

I suppose ASP/VBS?
Is there anything else I could have meant? No offence intended, but I at
least I tried :)
>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'>
function endCommasAway(x){ return x.replace(/,*$/,''); };
</script>
Is this using regular expressions? One day I will get around to learning
it, as it seems to be very popular. Could you explain what its doing?

Cheers,

Steve
Jan 8 '08 #4
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
Evertjan. wrote:
>Dooza wrote on 08 jan 2008 in
microsoft.public.inetserver.asp.general:
>>Using ASP/VB

I suppose ASP/VBS?

Is there anything else I could have meant? No offence intended, but I
at least I tried :)
Well, either ASP or VB.

Why offence?
>
>>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'>
function endCommasAway(x){ return x.replace(/,*$/,''); };
</script>

Is this using regular expressions? One day I will get around to
learning it, as it seems to be very popular. Could you explain what
its doing?
Better start experimenting with regex and reading a tutorial
and perhaps some specs, if all else fails.

<http://www.google.com/search?q=regex%20tutorial>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 8 '08 #5
Dooza wrote:
Dooza wrote:
>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

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,",")
%>
str=",,a,b,c,"
Much more simply:
a=split(str(",") 'create array by splitting str on commas
str=join(a,",") 'create str by joining array elements with commas
Response.write ctrim(str,",")

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jan 8 '08 #6
Evertjan. wrote:
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
>Evertjan. wrote:
>>Dooza wrote on 08 jan 2008 in
microsoft.public.inetserver.asp.general:

Using ASP/VB
I suppose ASP/VBS?
Is there anything else I could have meant? No offence intended, but I
at least I tried :)

Well, either ASP or VB.
Surely stating ASP and VB in an ASP newsgroup would mean that I want to
use ASP and VBScript, but I can see why it *could* be seen as me saying
I am using ASP and Visual Basic.
Why offence?
Because I didn't want to offend, I was being polite.
>>>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'>
function endCommasAway(x){ return x.replace(/,*$/,''); };
</script>
Is this using regular expressions? One day I will get around to
learning it, as it seems to be very popular. Could you explain what
its doing?

Better start experimenting with regex and reading a tutorial
and perhaps some specs, if all else fails.
Fair enough, another item on my to do list :)

Steve
Jan 8 '08 #7
Bob Barrows [MVP] wrote:
Dooza wrote:
>Dooza wrote:
>>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
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,",")
%>
str=",,a,b,c,"
Much more simply:
a=split(str(",") 'create array by splitting str on commas
str=join(a,",") 'create str by joining array elements with commas
Response.write ctrim(str,",")
Hi Bob,
I am currently using this:
firstname = Split(ctrim(Session("firstname"),","),",")

Steve
Jan 8 '08 #8
Dooza wrote:
>Why offence?

Because I didn't want to offend, I was being polite.
You have failed to answer the question he asked, but it's
understandable. Instead of "Why offence", the question should have been
worded: "why did you assume I was offended?"

The answer: Evertjian's terse replies are often interpreted as being the
result of annoyance, rather than the desire to pack the maximum amount
of information into as few words as possible, with the additional
limitation that English is not his native language.
I will say again (for those that missed it the first time): beware of
attempting to read emotion into text messages.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jan 8 '08 #9
Bob Barrows [MVP] wrote:
Dooza wrote:
>>Why offence?
Because I didn't want to offend, I was being polite.

You have failed to answer the question he asked, but it's
understandable. Instead of "Why offence", the question should have been
worded: "why did you assume I was offended?"

The answer: Evertjian's terse replies are often interpreted as being the
result of annoyance, rather than the desire to pack the maximum amount
of information into as few words as possible, with the additional
limitation that English is not his native language.
I will say again (for those that missed it the first time): beware of
attempting to read emotion into text messages.
Hi Bob, I have noted your comments on previous occasion, so knew it was
a language thing, I tried to reply as best I could.

Evertjian, I didn't assume you were offended, I actually meant that I
didn't want to offend you in the reply I was making...maybe I need to
brush on my English :)

Steve
Jan 8 '08 #10
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
Evertjian, I didn't assume you were offended, I actually meant that I
didn't want to offend you in the reply I was making...maybe I need to
brush on my English :)
Hi Steve,

I am not that easily offended.

Since you are possibly new to Usenet or this NG: questions are not always
what they seem, but are ment to keep the record straight for other
readers.

So talking about VB in asp needs correction, because many need to know
the difference reading the postings now or later from the archive. That
does not mean I think you personally don't know the difference.

Usenet posting is not emailing but more like broadcasting, and in a radio
talk the visitor is not answering only to the curiosity of the host,
as both questions and answers have information impact on others.

Further more, this is an international NG, so the niceties of local
English slang are largely wasted and should not be expected. English is
just a tool for communication.

Which should not mean a joke now and then is wasted on this NG, as I see
it.

Do you know the story of the Rabbi and the response object?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 8 '08 #11
Evertjan. wrote:
Dooza wrote on 08 jan 2008 in microsoft.public.inetserver.asp.general:
>Evertjian, I didn't assume you were offended, I actually meant that I
didn't want to offend you in the reply I was making...maybe I need to
brush on my English :)

Hi Steve,

I am not that easily offended.

Since you are possibly new to Usenet or this NG: questions are not always
what they seem, but are ment to keep the record straight for other
readers.
I am a relative newbie, I started in 1997 in the macromedia newsgroups,
its where I learnt my trade. Also I was a regular user at uk.music.rave
for many years until the popularisation of forums.
So talking about VB in asp needs correction, because many need to know
the difference reading the postings now or later from the archive. That
does not mean I think you personally don't know the difference.

Usenet posting is not emailing but more like broadcasting, and in a radio
talk the visitor is not answering only to the curiosity of the host,
as both questions and answers have information impact on others.

Further more, this is an international NG, so the niceties of local
English slang are largely wasted and should not be expected. English is
just a tool for communication.

Which should not mean a joke now and then is wasted on this NG, as I see
it.
I do see what your saying, using the correct netiquete is something I
thought I had cracked, but not using a truly international newsgroup
like this, where the topic is very specific, I still need to be careful.
Do you know the story of the Rabbi and the response object?
No I dont...

Steve
Jan 9 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
6
by: Rimuen | last post by:
Have a string contains numbers from database. But there is similar numbers want to remove Example: 1,3,6,6,6,12,13,14,15,15,15,15 Want to remove the similar numbers so it would be like:...
8
by: Joseph | last post by:
I have a textBox that people writes stories in it. They can use for format. I have Aspell installed on the server, so people can make correction to their text. Sometimes, they forget to add a...
22
by: ineedyourluvin1 | last post by:
Hello all! I've been looking for a way to strip characters from strings such as a comma. This would be great for using a comma as a delimiter. I show you what I have right now. ...
7
by: Mike | last post by:
I want to remove all commas from a numerical form field. I know that Replace(",", "") will to the job, but Replace(',', '') seems more appropriot but does not work. Any efficient suggestions...
4
by: Kun | last post by:
i have an html/cgi input that takes in values to a mysql database, however, if i stick in $20 instead of 20, it crashes the program because of the extra $ sign. I was wondering if anyone has a...
4
by: sherifffruitfly | last post by:
Hi all, I've got a csv file for numeric data, some of which are greater than 10^3. Some bright fellow trying to br helpful put US-standard commas in these numbers, and to maintain the correct...
7
by: santoshsri | last post by:
Hello all, I am entangled in a difficult situation. I wish to remove commas in a string ( for example : 1,20,000 ) that is coming as an output from another system. I will have to process the...
26
by: Brad | last post by:
I'm writing a function to remove certain characters from strings. For example, I often get strings with commas... they look like this: "12,384" I'd like to take that string, remove the comma...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.