Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Can RegExp() do this?? Date: Sun, 08 Feb 2015 15:17:27 +0100 Organization: PointedEars Software (PES) Lines: 34 Message-ID: <5013331.C6z0DViB7m@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1423405093 10020 eJwVycEBwCAIA8CVUEio4xQl+49Q+72Dc3BnEAwIMifynfbjONIq+M3nrkV5pKN7NXOHqqAP/ewQfw== (8 Feb 2015 14:18:13 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 8 Feb 2015 14:18:13 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNx8EBwEAEBMCWXMKinGPpv4RkfmMvDtoVBrW1RdiforjcXpHETWEraw/nVPLxcg7dL9vGO7VjpDkYBD9mdxbD Cancel-Lock: sha1:5y41rfGZAoK00Jz/FjmVDbLNv+w= X-NNTP-Posting-Host: eJwNxsERACEIA8CWQEzClcOI9F+Ct69F0Hm0CW4MJs2zsuyvrb4u3v5UE2ax1IcOB1ZKohXwAA66EBE= Xref: csiph.com comp.lang.javascript:26820 dean@hannotte.com wrote: ^^^^^^^^^^^^^^^^^ Your real name belongs there. > How can I highlight all cases of "this", for example, without > unintentionally highlighting cases of "this" that occur within islands of > HTML and META-HTML. Is that a question? ^ You can use String.prototype.replace() passing a reference to a RegExp instance with alternation and global flag set while giving precedence to the alternatives that match substrings that you wish to ignore, and a reference to a Function instance for replacer function. Then return from that function the match for them, and the highlighted match for the rest. That said, at your current position in the learning curve you should not attempt to parse provably non-regular languages like HTML using regular expressions. > IS THIS POSSIBLE? Yes. Please do not shout. And do not use the borked, spammed, and troll-infested Google Groups for posting; use a decent newsreader. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.