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

70
Visualizações
Is there a way to do a lazy lookbehind?

I have some HTML text like below.

                <div style="background:#e0dddd; color:#333399; font:9PT 'arial'; padding:10px; margin-left:-30px; ">
                    <div>
                        <strong>Some text here1 </strong><br />
                        2021-08-08                    </div>

                    <div><p>
    Some text here2</p>
</div>
                    <div class="download">
                        <a href="index.php?obj=notice_id=1734">View Detail ...</a>
                    </div>
                </div>
                
                <div style="background:#e2ecf4; color:#333399; font:9PT 'arial'; padding:10px; margin-left:-30px; ">
                    <div>
                        <strong>Some text 3</strong><br />
                        2021-08-06                    </div>

                    <div><p>
    Some BE text 4.</p>
</div>
                    <div class="download">

What I'm trying to capture is the following, basically, from the tag <strong> onwards to the line that has BE in it. It can be case insensitive.

Some text 3</strong><br />
                        2021-08-06                    </div>

                    <div><p>
    Some BE text 4.

I'm using /(?<=<strong>)[\s\S]*?b[ _\/,]?e[\W][\s\S]*?(?=<)/gim but it captures the following.

Some text here1 </strong><br />
                        2021-08-08                    </div>

                    <div><p>
    Some text here2</p>
</div>
                    <div class="download">
                        <a href="index.php?obj=notice_id=1734">View Detail ...</a>
                    </div>
                </div>

                <div style="background:#e2ecf4; color:#333399; font:9PT 'arial'; padding:10px; margin-left:-30px; ">
                    <div>
                        <strong>Some text 3</strong><br />
                        2021-08-06                    </div>

                    <div><p>
    Some BE text 4.

What am I doing wrong here?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I suggest a DOM based solution to iterate over the div elements (at the root level). Then a simple test on the inner text suffices to get the good one:

const parser = new DOMParser();
const doc = parser.parseFromString(`<div id="root">${yourhtml}</div>`, 'text/html');
doc.querySelectorAll('#root > div').forEach(function(el) {
    let text = el.innerText;
    if ( /\bb[^ ,_\/]?e\b/i.test(text) )
        console.log(text); // display in your browser console
});
about 4 years ago · Juan Pablo Isaza Relatório
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