Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!news.xs4all.nl!not-for-mail Newsgroups: comp.lang.javascript Subject: Re: String Replace. Please, need help. From: "Evertjan." References: <11174912.1946.1318534920723.JavaMail.geo-discussion-forums@vbmh5> Message-ID: User-Agent: Xnews/2009.05.01 Date: 13 Oct 2011 21:17:46 GMT Lines: 26 NNTP-Posting-Host: 188.142.37.124 X-Trace: 1318540666 news2.news.xs4all.nl 2484 ehannivo/188.142.37.124:50681 Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:7368 Shapper. wrote on 13 okt 2011 in comp.lang.javascript: > Hello, > > 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}". Use regular expressions in stead of a string. > When it does not have I get an error. Is that a question or a statement? > How can I solve this? What error do you get? It seems to me that the replace() works fine even if there is nothing to replace. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)