Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type: text/plain; charset="UTF-8"
Message-ID: <2116422.PPeRs11RAM@PointedEars.de>
From: Thomas 'PointedEars' Lahn
"; > > Then I do this (to remove the outer "
..."): One wonders how it got there in the first place, since it is not Valid. One also wonders why you think you need to (or could, trivially) fix that. > s = s.replace(/^<\/([^> ]+)[^>]*>(.*)<\1>$/,"$2"); wrong This expression does _not_ accurately match HTML tags or elements, or XML tags or elements for that matter. See HTML5 (CR) and XHTML 1.0/1.1 (REC) for details. > Nothing happens (s is unchanged, and if I use match() instead of replace > it returns false), but if I go try it at > http://www.regular-expressions.info/javascriptexample.html, it works! > > I've tried all sorts of things (creating a separate regExp object, using > //g, taking out the ^$, replacing [^> ]+ with [a-z0-9]*...) but nothing > makes any difference. > > It's driving me nuts. Can anyone tell me what I'm doing wrong here? You are using “.” which does not match "\n", so that expression matches as far as
`---'`-----------' : : : '-------. : : ,----------------.,--. ^<\/([^> ]+)[^>]*>(.*)<\1>$ (use a fixed-width font). Then it fails, because "\n" is not matched by “<”. That said, like so many other people before you, you are trying to apply an expression describing a Chomsky type-3 language to match a sentence of a text in a Chomsky type-2 language, which usually *must* fail. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.