Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37141
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: string.replace() |
| Date | 2019-08-14 15:41 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <qj1v5t$4q0$1@dont-email.me> (permalink) |
| References | <qiv5ub$i5$1@dont-email.me> <replace-20190814002416@ram.dialup.fu-berlin.de> <XnsAAAB68E927159eejj99@194.109.6.166> |
Evertjan. wrote: > However, > since there are other characters that produce a visible space, > like the tab charater for instance, > you possibly could prefer to use the \s for 'any spacelike character': > > myString = myString.replace( /\s/g, '+' )); The strings are mine (as opposed to user input) so either will do. This suggestion is more general, and so more bullet proof, so I will use it. > If you are unsure about using Regex, > replace() can also, in a simple way, be used without that: > > myString = myString.replace( ' ', '+' )); > > but then the /g for 'global' would not be there, > and only the first instance of a space would be replaced. My original post explained that there can be more than one space, so I have to use a regular expression. Thanks for your help. -- Regards, Martin Leese E-mail: please@see.Web.for.e-mail.INVALID Web: http://members.tripod.com/martin_leese/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
string.replace() Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-08-13 14:18 -0600
Re: string.replace() dr.j.r.stockton@gmail.com - 2019-08-13 14:52 -0700
Re: string.replace() Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-08-14 15:36 -0600
Re: string.replace() "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-14 10:18 +0200
Re: string.replace() Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-08-14 15:41 -0600
Re: string.replace() "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-15 13:55 +0200
csiph-web