473,666 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10469
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,trims tr)
while trim(left(str,1 ))=trimstr
str=trim(right( str,Len(str)-1))
wend
while trim(right(str, 1))=trimstr
str=trim(Left(s tr,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.publi c.inetserver.as p.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='jscri pt' 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.publi c.inetserver.as p.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='jscri pt' 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.publi c.inetserver.as p.general:
Evertjan. wrote:
>Dooza wrote on 08 jan 2008 in
microsoft.publ ic.inetserver.a sp.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.wri te endCommasAway(s )
%>

<script language='jscri pt' 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,trims tr)
while trim(left(str,1 ))=trimstr
str=trim(right( str,Len(str)-1))
wend
while trim(right(str, 1))=trimstr
str=trim(Left(s tr,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.publi c.inetserver.as p.general:
>Evertjan. wrote:
>>Dooza wrote on 08 jan 2008 in
microsoft.pub lic.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.writ e endCommasAway(s )
%>

<script language='jscri pt' 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,trims tr)
while trim(left(str,1 ))=trimstr
str=trim(right( str,Len(str)-1))
wend
while trim(right(str, 1))=trimstr
str=trim(Left(s tr,Len(str)-1))
wend
ctrim=str
end function

<%
str=",,a,b,c ,"
Response.wri te 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(Ses sion("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

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

Similar topics

12
55549
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 also removed) So far I have (val is value, ar is array, returns new array):
6
1773
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: 1,3,6,12,13,14,15 Any help ??
8
4190
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 space after a period. So Aspell reads the last word of a sentence and the first word of the next sentence as a single world, which gives an error, word not found. Before sending the text to Aspell, i add a space after all the periods with:
22
13758
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. #include<iostream> #include<string> int main(int argc, char *argv) {
7
6029
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 would be appreciated. Thank, Mike
4
11639
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 quick regular expression in python to remove the $-sign if it is present in the input.
4
25206
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 cell-index put quotation marks around the comma'd result. Example csv line: 43.56,345.2,"1,285,100",45.6
7
50998
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 output in my C# application. I will have to save 1,20,000 as 120000 in SQL2K database. Please let me know how to remove the commas from the string . I have tried String.Replace already but it is not working. Please help
26
13784
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 and return "12384" What is the most efficient, fastest way to approach this? Thanks,
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.