I would like to extract the pre-header from a HTML using regex. The HTML looks like this:
<!DOCTYPE html><html>
<head>...</head>
<body dir="ltr" style="padding: 0; margin: 0"><div style="display: none; max-height: 0px; overflow: hidden;">This is my preheader — </div><table cellspacing="0" cellpadding="0" style="width: 100%">
...
</body></html>
This means that the pre-header is placed directly after the <body> start tag as a <div> element. Furthermore, it has the display: none style class. So I think it would be best to extract the first element after the <body> start tag, then check if it's a <div> with corresponding style class (otherwise no pre-header maintained) and if so, extract the text from it ignoring escapes and stuff like —.
I would like to implement this in JavaScript. It would help me very much to 1) know the regex to extract the first element after the <body> start tag and 2) extract the plain text value from the <div> element.
Thank you very much for assistance in advance.