Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Get pre-header from HTML using regex

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 &mdash; </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 &mdash;.

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda