Hi,
I have a string that contains n items. Each item start with a '@' and the
item itself does not contains the '@a'.
For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four".
So in fact the first '@' can be removed, the next except the last replaces
by ", " and the last one by the word "and ".
Is there a simple way doing this?
Frank 13 14024
Dropstengel wrote on 17 aug 2004 in comp.lang.javascript : Hi,
I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'. For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
s = "@one@two@three@four"
s = s.substr(1).split('@').join(',').replace(/,([^,]+)$/,' and $1')
alert(s)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dropstengel <ik@haat.spam> wrote:
Both your From and Reply-To addresses do not specify mailboxes which is
aviolation of Internet/Usenet standards and disregarding the Netiquette
s well as most certainly a violation of the Acceptable Use Policy of your
service provider. You have been warned. I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'.
^^ Is this a typo?
For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
Assuming that the above is a typo:
var
s = "@one@two@three@four",
i = s.lastIndexOf("@");
[s.substring(1, i).split("@").join(", "), s.substr(i + 1)].join(" and ")
PointedEars
--
So, somebody DOES read these!
Dropstengel <ik@haat.spam> wrote:
Both your From and Reply-To addresses do not specify mailboxes which is
a violation of Internet/Usenet standards and disregarding the Netiquette
as well as most certainly a violation of the Acceptable Use Policy of
your service provider. You have been warned. I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'.
^^ Is this a typo?
For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
Assuming that the above is a typo:
var
s = "@one@two@three@four",
i = s.lastIndexOf("@");
[s.substring(1, i).split("@").join(", "), s.substr(i + 1)].join(" and ")
PointedEars
--
So, somebody DOES read these!
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29... Dropstengel wrote on 17 aug 2004 in comp.lang.javascript:
Hi,
I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'. For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
s = "@one@two@three@four"
s = s.substr(1).split('@').join(',').replace(/,([^,]+)$/,' and $1')
alert(s) -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
Evertjan, bedankt (thanks)
Now I see that it is quit simple....
It is an accident that I code something up in JavaScript...
Frank
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:14****************@PointedEars.de... Dropstengel <ik@haat.spam> wrote:
Both your From and Reply-To addresses do not specify mailboxes which is a violation of Internet/Usenet standards and disregarding the Netiquette as well as most certainly a violation of the Acceptable Use Policy of your service provider. You have been warned.
Do you warn everybody?
PointedEars --
Frank
On Tue, 17 Aug 2004 21:08:07 +0200, Dropstengel <ik@haat.spam> wrote:
[snipped drivel on munged addresses] Do you warn everybody?
Unfortunately, yes, he does. Most people just ignore it and move on to the
useful things he says. I suggest you do the same. :)
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Dropstengel wrote: "Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message Dropstengel <ik@haat.spam> wrote: Both your From and Reply-To addresses do not specify mailboxes which is a violation of Internet/Usenet standards and disregarding the Netiquette as well as most certainly a violation of the Acceptable Use Policy of your service provider. You have been warned.
Do you warn everybody?
Almost everybody who perpetrates this violation. If I take the time
and the *continuing* behavior is also a violation of the Acceptable
Use Policy of the respective service provider's AUP, the SP is informed
about the case of network abuse in a formal complaint. The respective
poster is always killfiled on NetNews with its invalid From (so that
their postings are no longer filtered if they changed it to something
that is in accordance with the Net's standards/the Netiquette).
F'up2 PointedEars, Score adjusted
--
All I wanted was a little bit of time to myself. Then they started
mozilla.org. Bastards.
Dropstengel wrote: "Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message Dropstengel <ik@haat.spam> wrote: Both your From and Reply-To addresses do not specify mailboxes which is a violation of Internet/Usenet standards and disregarding the Netiquette as well as most certainly a violation of the Acceptable Use Policy of your service provider. You have been warned.
Do you warn everybody?
Almost everybody who perpetrates this violation. If I take the time and
the *continuing* behavior is also a violation of the Acceptable Use Policy
of the respective service provider, the SP is informed about the case of
network abuse in a formal complaint. The respective posters are always
killfiled on NetNews with their invalid From (so that their postings are no
longer filtered if they changed it to something that is in accordance with
the Net's standards/the Netiquette).
F'up2 PointedEars, Score adjusted
--
All I wanted was a little bit of time to myself. Then they started
mozilla.org. Bastards.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opscv5h7fhx13kvk@atlantis... On Tue, 17 Aug 2004 21:08:07 +0200, Dropstengel <ik@haat.spam> wrote:
[snipped drivel on munged addresses]
Do you warn everybody? Unfortunately, yes, he does. Most people just ignore it and move on to the useful things he says. I suggest you do the same. :)
Yes, I'd love to..thanks.
Mike
-- Michael Winter Replace ".invalid" with ".uk" to reply by e-mail
Frank
Dropstengel wrote: "Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message news:14****************@PointedEars.de...
Dropstengel <ik@haat.spam> wrote:
Both your From and Reply-To addresses do not specify mailboxes which is a violation of Internet/Usenet standards and disregarding the Netiquette as well as most certainly a violation of the Acceptable Use Policy of your service provider. You have been warned.
Do you warn everybody?
Nah, he only warns those that he notices. And when pressed, he cites an
article that is outdated and totally rubbish. I have asked several times
(of him) to explain the difference between a From address that does not
specify a mailbox and a From address that specifies a mailbox that can
not recieve email. In either case, you can't email the person. I guess
he has never explained it because he can't grasp the simple idea "It
doesn't matter".
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
JRS: In article <41***********************@news.xs4all.nl>, dated Tue,
17 Aug 2004 21:08:07, seen in news:comp.lang.javascript, Dropstengel
<ik@haat.spam> posted : "Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message news:14****************@PointedEars.de... Dropstengel <ik@haat.spam> wrote:
Both your From and Reply-To addresses do not specify mailboxes which is a violation of Internet/Usenet standards and disregarding the Netiquette as well as most certainly a violation of the Acceptable Use Policy of your service provider. You have been warned.
Do you warn everybody?
Unfortunately, more or yes less. The Germans have not entirely lost the
offensive habits displayed in 1914 ff and 1933 ff.
IMHO, the nicer ones need to explain to Lahn the error of his ways.
--
© John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
In MS OE, choose Tools, Options, Send; select Plain Text for News and E-mail.
Dropstengel wrote: Hi,
I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'. For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
Frank
"@one@two@three@four".substring(1).split("@").join (",")
Mick
"Dropstengel" <ik@haat.spam> wrote in message news:<41***********************@news.xs4all.nl>... Hi,
I have a string that contains n items. Each item start with a '@' and the item itself does not contains the '@a'. For example the string looks like: "@one@two@three@four"
I have to output this string as "one, two, three and four". So in fact the first '@' can be removed, the next except the last replaces by ", " and the last one by the word "and ". Is there a simple way doing this?
Frank
The easiest way to do this, I think, is with a regex.
Then, do your split() as normal.
Shawn
Tested code:
<script type="text/javascript">
myString = '@one@two@three@four';
myString = myString.replace(/^@(.*)$/, '$1');
alert(myString);
</script> This discussion thread is closed Replies have been disabled for this discussion. Similar topics
8 posts
views
Thread by moondaddy |
last post: by
|
9 posts
views
Thread by Python.LeoJay |
last post: by
|
3 posts
views
Thread by SharpCoderMP |
last post: by
|
6 posts
views
Thread by trevor |
last post: by
| | |
2 posts
views
Thread by Mika M |
last post: by
| | | | | | | | | | | | |