Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

69
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda