regex - Using Javascript and Regular expression to get content inside the html body -



regex - Using Javascript and Regular expression to get content inside the html body -

possible duplicate: how extract body contents using regexp

i have response text having total page content html,head,body.i want content within body.how accomplish using regx.please help accomplish this.

a dom parser reliable method extracting info this, regex can pretty decent job if html sane. (i.e. text: <body or: </body not occur within comments, scripts, stylesheets, cdata sections or attribute values. , body element start tag attributes not contain the: > character.) regex captures contents of first innermost body element (should ever one):

var bodytext = ''; var m = text.match(/<body[^>]*>([^<]*(?:(?!<\/?body)<[^<]*)*)<\/body\s*>/i); if (m) bodytext = m[1];

it implements jeffrey friedl's "unrolling-the-loop" efficiency technique quite fast.

javascript regex

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -