Remove commas from end of string
Remove commas from end of string
am 08.01.2008 13:09:09 von Dooza
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
Re: Remove commas from end of string
am 08.01.2008 13:25:03 von Dooza
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
Re: Remove commas from end of string
am 08.01.2008 13:25:59 von exjxw.hannivoort
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)
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Remove commas from end of string
am 08.01.2008 14:00:04 von Dooza
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)
> %>
>
>
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
Re: Remove commas from end of string
am 08.01.2008 14:16:21 von exjxw.hannivoort
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)
>> %>
>>
>>
>
> 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.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Remove commas from end of string
am 08.01.2008 14:32:58 von reb01501
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.
Re: Remove commas from end of string
am 08.01.2008 15:13:36 von Dooza
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)
>>> %>
>>>
>>>
>> 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
Re: Remove commas from end of string
am 08.01.2008 15:23:52 von Dooza
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
Re: Remove commas from end of string
am 08.01.2008 15:33:33 von reb01501
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.
Re: Remove commas from end of string
am 08.01.2008 17:08:15 von Dooza
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
Re: Remove commas from end of string
am 08.01.2008 22:58:20 von exjxw.hannivoort
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)
Re: Remove commas from end of string
am 09.01.2008 10:08:39 von Dooza
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