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


Groups > comp.lang.javascript > #9351

Re: String.replace() with regex

From Hans-Georg Michna <hans-georgNoEmailPlease@michna.com>
Newsgroups comp.lang.javascript
Subject Re: String.replace() with regex
Date 2011-12-17 18:31 +0100
Organization albasani.net
Message-ID <cckpe7t2ntjluiaqvbpotsktgq7kr74ga5@4ax.com> (permalink)
References <16483917.24.1324118524679.JavaMail.geo-discussion-forums@yqlp16>

Show all headers | View raw


On Sat, 17 Dec 2011 02:42:04 -0800 (PST), Jason C wrote:

>I have this regex, which works as expected:
>
>a = a.replace(/ itxtHarvested="(.*?)"/i, "");
>
>I modified it to this:
>
>a = a.replace(/\s*itxtHarvested="*(.*?)"*/i, "");

The inner parentheses serve no purpose. I would remove them.

If, however, you are actually trying to match parentheses, then
you have to escape them: \( \)

Hans-Georg

Back to comp.lang.javascript | Previous | Next — Previous 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