Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22633
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Removing ' ' from strings ?? |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <bjog40Fe7h5U1@mid.individual.net> |
| Date | 2014-01-15 23:35 +0100 |
| Message-ID | <XnsA2B6F00B7DFE3eejj99@194.109.133.133> (permalink) |
"Mel Smith" <med_cutout_syntel@aol.com> wrote on 15 jan 2014 in
comp.lang.javascript:
> Hi:
>
> I'm probably having a senior moment, but with IE8 as a test bed, I
> cannot seem to replace ' ' with an ordinary space character.
>
> e.g.,
>
> Let's say my input text string is:
>
> var mytext = " " + "Hello" + " " + "World" +
> " "
>
> Using IE8:
>
> var newtext = mytext.replace(" "," ") ;
>
> The above statement*works* in Chrome (i.e., it replaces ' '
> with an 'ordinary' space character
No, only the first one.
>
> But, in IE8 , these ' ' sequences are *not* replaced -- just
> ignored ??
IE11 does the same as chrome, are you sure about IE8?
> I need a 'kick-in-the-butt' please -- perhaps a real regex string that
> would work in all cases ?
Better always use regex with replace(),
and use the global switch if necessary:
var newtext = mytext.replace(/ /g,' ') ;
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-15 15:23 -0700
Re: Removing ' ' from strings ?? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-15 23:35 +0100
Re: Removing ' ' from strings ?? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-15 23:44 +0000
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-15 17:07 -0700
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 09:08 -0700
Re: Removing ' ' from strings ?? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-16 16:18 +0000
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 10:23 -0700
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 10:35 -0700
Re: Removing ' ' from strings ?? Martin Honnen <mahotrash@yahoo.de> - 2014-01-16 18:58 +0100
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 11:05 -0700
Re: Removing ' ' from strings ?? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-01-16 18:01 +0000
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 11:10 -0700
Re: Removing ' ' from strings ?? Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-16 19:17 +0000
Re: Removing ' ' from strings ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2014-01-16 13:37 -0700
csiph-web