0

For my little web app I'm using data from an external site, retrieving with AJAX-requests. The idea is to parse the correct data out the plaintext html-data using a simple JavaScript parser (there are a couple on the net).

Unfortunately for me, the external site uses a stupid CMS which spews out as meta-tag.

As you would already notice, the content-attribute is missing a " and the htmlparser doesn't like that.

I thought it isn't a big deal when I'll just replace it. Code to probe here:

// Obviously the rest of the html is cut out to make it more readable:
var data = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>";

data.replace( /\"text\/html;/gi, "\"text/html\"" );

console.log( data );

Unfortunately it didn't work, and I'd like to keep the \"text/html; part in the regex instead of html; for example to make sure that other things in the data don't break. I tried may variations of this regex (like removing the \", adding .+ and so on), but it didn't work either.

What is going wrong here?

RoestVrijStaal
  • 151
  • 2
  • 7
  • For future reference, see http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – elclanrs May 21 '14 at 22:06
  • @elclanrs: That's a very bad answer. Not helping in any way at all. This question is not intended to deal with htmlparsing. – RoestVrijStaal May 21 '14 at 22:12

0 Answers0