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


Groups > comp.lang.javascript > #9348

String.replace() with regex

From Jason C <jwcarlton@gmail.com>
Newsgroups comp.lang.javascript
Subject String.replace() with regex
Date 2011-12-17 02:42 -0800
Organization http://groups.google.com
Message-ID <16483917.24.1324118524679.JavaMail.geo-discussion-forums@yqlp16> (permalink)

Show all headers | 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