Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #7495

Re: String Replace. Please, need help.

From Dr J R Stockton <reply1141@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: String Replace. Please, need help.
Date 2011-10-16 19:30 +0100
Organization Home
Message-ID <rhM1xtERLymOFw14@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <11174912.1946.1318534920723.JavaMail.geo-discussion-forums@vbmh5> <TbAb$2ChVJmOFwB5@invalid.uk.co.demon.merlyn.invalid> <Xns9F7F75787FD54eejj99@194.109.133.246>

Show all headers | View raw


In comp.lang.javascript message <Xns9F7F75787FD54eejj99@194.109.133.246>
, Sat, 15 Oct 2011 09:32:49, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Dr J R Stockton wrote on 14 okt 2011 in comp.lang.javascript:
>
>> In comp.lang.javascript message <11174912.1946.1318534920723.JavaMail.ge
>> o-discussion-forums@vbmh5>, Thu, 13 Oct 2011 12:42:00, Shapper.
>> <mdmoura@gmail.com> posted:
>>
>>>I am using "replace" as follows:
>>>
>>>content = source.replace("{id}", options.id).replace("{title}", title);
>>>
>>>However "source" might have or not have the strings "{id}" and "{title}".
>>>When it does not have I get an error.
>>>How can I solve this?
>>
>> Use
>>         X = source.replace("{id}", options.id)
>>         content = X.replace("{title}", title)
>> and then you can test that in each case a change has been made, by
>> comparing the strings with == or != .
>
>Yes, but that would not solve this:
>
>>> However "source" might have or not have
>>> the strings "{id}" and "{title}".
>>> When it does not have I get an error.
>
>as replace() should not give an error, when there is nothing to replace.
>
>better try:
>
>alert( content = source.replace("{id}", options.id) );
>alert( content = X.replace("{title}", title) );
>
>I suspect the error won't show till after ok-ing the alerts.


You appear to be assuming that you, a Netherlander who is pretty good at
understanding and writing proper English, has perfectly understood the
intended meaning of what has been written by someone who seems to be an
Iberian, or possibly an American.  A smart Iberian would have posted
bilingually, in good Iberian and in English - many of us here are, as
you exemplify, not monoglots.

In particular, we do not know for certain whether the OP got an error
message for that code from the script engine, or an error message from
the script engine later on, or an error report from some sort of
checking later on.

The OP should have given the exact error message, and enough code to
reproduce the problem, and the input used, and the outputs obtained and
desired..  The OP should also have said which browser(s) and which OS
were in use, just in case it matters.

Perhaps the OP had not read <http://www.jibbering.com/faq/index.html>,
which is UP.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

String Replace. Please, need help. "Shapper." <mdmoura@gmail.com> - 2011-10-13 12:42 -0700
  Re: String Replace. Please, need help. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-10-13 21:17 +0000
  Re: String Replace. Please, need help. "Tom de Neef" <tdeneef@qolor.nl> - 2011-10-14 09:43 +0200
    Re: String Replace. Please, need help. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-14 21:01 +0200
  Re: String Replace. Please, need help. Dr J R Stockton <reply1141@merlyn.demon.co.uk> - 2011-10-14 21:02 +0100
    Re: String Replace. Please, need help. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-10-15 09:32 +0000
      Re: String Replace. Please, need help. Luuk <Luuk@invalid.lan> - 2011-10-15 11:47 +0200
        Re: String Replace. Please, need help. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-10-15 10:04 +0000
          Re: String Replace. Please, need help. Luuk <Luuk@invalid.lan> - 2011-10-15 12:14 +0200
            Re: String Replace. Please, need help. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-10-15 12:21 +0000
              Re: String Replace. Please, need help. Andreas Bergmaier <andber93@web.de> - 2011-10-15 22:49 +0200
                Re: String Replace. Please, need help. Antony Scriven <adscriven@gmail.com> - 2011-10-15 15:37 -0700
                Re: String Replace. Please, need help. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-16 01:08 +0200
      Re: String Replace. Please, need help. Dr J R Stockton <reply1141@merlyn.demon.co.uk> - 2011-10-16 19:30 +0100
  Re: String Replace. Please, need help. Bart Lateur <bart.lateur@telenet.be> - 2011-10-18 19:49 +0200

csiph-web