Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1929900.aqSPkdTlGX@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 17 Dec 2011 14:12:14 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: String.replace() with regex Newsgroups: comp.lang.javascript References: <16483917.24.1324118524679.JavaMail.geo-discussion-forums@yqlp16> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 59 NNTP-Posting-Date: 17 Dec 2011 14:12:15 CET NNTP-Posting-Host: 06e5dfe2.newsspool2.arcor-online.net X-Trace: DXC=nHl45987DKoFXUDVUnEXQmA9EHlD;3Ycb4Fo<]lROoRa8kF I have this regex, which works as expected: > > a = a.replace(/ itxtHarvested="(.*?)"/i, ""); > > I modified it to this: > > a = a.replace(/\s*itxtHarvested="*(.*?)"*/i, ""); > > which I thought would be the same, but would make the /s and " optional. How can it be the same then? It would make leading white-space, and optional in that it would allow 0 or more of them, including `"""""'. (This is probably not what you want.) > But, in practice, instead of just removing it, it was being converted to > something like: > > 441?0? > > (Or maybe 530"0"; I had made several modifications using the *, and now I > don't remember which error went where.) No, it was not. > Does the * not mean "0 or more times" in Javascript like it does in other > languages? There is no "Javascript": The `*' means the same in ECMAScript implementations as in other programming languages. > I know that a few things are different with JS (like the /s > modifier), so I wasn't sure. ECMAScript Regular Expressions do not natively support several PCRE features, but you can emulate some. I have recently finished emulating support for Unicode character property escape sequences, named subpatterns, and the `x' modifier: > Or, is it just something flawed in my logic that made it not work as > expected? Both your logic and your question are flawed. PointedEars -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16