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


Groups > comp.lang.javascript > #9348

String.replace() with regex

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.42!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Jason C <jwcarlton@gmail.com>
Newsgroups comp.lang.javascript
Subject String.replace() with regex
Date Sat, 17 Dec 2011 02:42:04 -0800 (PST)
Organization http://groups.google.com
Lines 17
Message-ID <16483917.24.1324118524679.JavaMail.geo-discussion-forums@yqlp16> (permalink)
Reply-To comp.lang.javascript@googlegroups.com
NNTP-Posting-Host 67.237.93.23
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1324118617 28864 127.0.0.1 (17 Dec 2011 10:43:37 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Sat, 17 Dec 2011 10:43:37 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=67.237.93.23; posting-account=494U9QkAAACJUH6jIcyb5E30maZZLsu7
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:9348

Show key headers only | View raw


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. 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.)

Does the * not mean "0 or more times" in Javascript like it does in other languages? I know that a few things are different with JS (like the /s modifier), so I wasn't sure.

Or, is it just something flawed in my logic that made it not work as expected?

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


Thread

String.replace() with regex Jason C <jwcarlton@gmail.com> - 2011-12-17 02:42 -0800
  Re: String.replace() with regex Stefan Weiss <krewecherl@gmail.com> - 2011-12-17 14:08 +0100
  Re: String.replace() with regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-17 14:12 +0100
  Re: String.replace() with regex Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2011-12-17 18:31 +0100

csiph-web