Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37145
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: string.replace() |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <qiv5ub$i5$1@dont-email.me> <replace-20190814002416@ram.dialup.fu-berlin.de> <XnsAAAB68E927159eejj99@194.109.6.166> <qj1v5t$4q0$1@dont-email.me> |
| Date | 2019-08-15 13:55 +0200 |
| Message-ID | <XnsAAAC8DB5EBF18eejj99@194.109.6.166> (permalink) |
Martin Leese <please@see.Web.for.e-mail.INVALID> wrote on 14 Aug 2019 in comp.lang.javascript: > 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. This is Usenet, not a helpdesk, so responses go to the group, and may exeed an original question. > Thanks for your help. It may be expedient for you to learn Regex syntax and methods, and not depend on thes same of others. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous 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