Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!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: Tue, 10 Feb 2015 17:04:07 +0100 Organization: PointedEars Software (PES) Lines: 28 Message-ID: <4359125.6fUziKdlIv@PointedEars.de> References: <5013331.C6z0DViB7m@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1423584292 10925 eJwFwQkBwDAIA0BL5UkAOaUM/xJ2B6PwhRN0LDZXrefILaF9NZRomWIPHO+o6rUTpZGWmMUPDx0QRA== (10 Feb 2015 16:04:52 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 10 Feb 2015 16:04:52 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYkBADAEBLCVKIeOo579R2gCMbZyNZhisRTzntBF8u6hTQ1cBXT6lHaLZwx3WaVZDeQhZ4jviWaX+V9yFe4= Cancel-Lock: sha1:5Opa/tOFp1q+cZy46/6bJP8ouGA= X-NNTP-Posting-Host: eJwdyscNADEIBMCWjrRAOSa4/xIs3bzHBIR2hUHt2v0GiLpK3Zvn5DqXCGv9JWtYVMozaHbS4gEerRDm Xref: csiph.com comp.lang.javascript:26835 Joao Rodrigues wrote: > Thomas 'PointedEars' Lahn wrote: >> 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 > ^^^^^ > > The OP doesn't seem to want parsing the HTML document here. For what they want they need to be able to tell apart matches within “script” elements and “meta-element islands” (as they call it; the resulting markup is probably invalid) from the other matches that they are interested in. That means parsing HTML (I did not say they would need to parse the entire document). Are you confusing parsing with rendering? HTH -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.