I have an html code block that is returned by an Ajax call. Now I want extract description and keywords meta tags from it.
success: function (data) {
//extracting page title by this way and it works as it should be ofc
var urlTitle = resultback.match(/<title>(.*?)<\/title>/);
urlTitle = urlTitle[1];
//extract description
//Currently using this method to retrieve description
var startpos, endpos;
startpos = endpos = 0;
var urlDescription = "";
startpos = data.indexOf('<meta name="description" content="') + 31
endpos = data.indexOf('" />', startpos)
urlDescription = $.trim(data.substring(startpos, endpos))
//What if meta tag is like this :
//<meta content="something" name="Description">
//thats my point of its "always not gonna work"
}
EDITED
should I create my own ReGex for this reason or there is already a ReGex for this.