Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1938247.aqSPkdTlGX@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 23 Feb 2012 14:36:45 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: Replace all strings Newsgroups: comp.lang.javascript References: <0794f674-e437-4d95-87b3-f1580418f1fb@sk8g2000pbc.googlegroups.com> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 34 NNTP-Posting-Date: 23 Feb 2012 14:36:47 CET NNTP-Posting-Host: 4547e10d.newsspool1.arcor-online.net X-Trace: DXC=[c`2l[H=AOm]l@YUW5NBknic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbEUa5a2c^AaoDZm8W4\YJNlUFDj8T]K0?cDmniOZG;K0k\QI_OT3i1Hm X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:12091 J.R. wrote: > On 22/02/2012 17:29, Archos wrote: >> On Feb 22, 6:48 pm, "J.R." wrote: >>> On 22/02/2012 15:48, Archos wrote: >>>> How to replace all strings at the same time? >>>>>>> var a = "a,b,c,d"; >>>>>>> a.toString().replace(",", "") >>>> "ab,c,d" >>> >>> If I understood correctly, you want to replace all the commas in a >>> variable with '', right? Then you might use a RegExp such as: >>> >>> var a = "a,b,c,d"; >>> a.replace(/,/g, '') >> Yes, thanks. I hope that the use of regular expressions been right for >> main browsers. > > The "searchValue" argument of the String.prototype.replace method can be > a regular expression or not, according to the standards (ECMA-262 > Editions 3 and 5, section 15.5.4.11). More importantly, the RegExp initialiser (sic!) and constructor are supported since at least JScript 5.5.6330 (IE 5.5), JavaScript 1.5 (NN6/Fx1), V8 3.6.6.19 (Cr16), JavaScriptCore 531.22.7 (Safari 4.0.5), Opera ECMAScript 7.02, KDE JavaScript 4.6.5 (Konqueror 4.6.5). PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee