I have the following code in jS :
function stripHTMLWithLinks(c) {
var BodyContents = /([\s\S]*\<body[^\>]*\>)([\s\S]*)(\<\/body\>[\s\S]*)/i ;
var h = c.match(BodyContents);
if (h != null && h[2]) {
c = h[2];
}
c = c.replace(/<a\s.*?href\s*=\s*"(.*?)".*?>(.*?)<\/a>/gi, "$2 [$1]");
c = c.replace(/<a\s.*?href\s*=\s*'(.*?)'.*?>(.*?)<\/a>/gi, "$2 [$1]");
c = c.replace(/\/\/--\>/gi, "");
c = c.replace(/(\n)/gi,"");
c = c.replace(/(\r)/gi,"");
c = c.replace(/<title[^\>]*\>[\s\S]*\<\/title\>/gi,"");
c = c.replace(/<br\s*\/\s*>/gi,"\n");
c = c.replace(/(<\/h.>|<\/p>|<\/div>)/gi, "$1\n\n");
c = c.replace(/<[^>]+>/g,"");
c = c.replace(/</g,"<");
c = c.replace(/>/g,">");
c = c.replace(/ /g," ");
return c;
}
I need a function that will extract the body content. All the examples that I saw here were kinda fixed on a particular example , and i need it on dynamic basis. This function can do it for me, I just need it in php.