Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

68
Views
¿Hay alguna manera de hacer una mirada perezosa hacia atrás?

Tengo un texto HTML como el siguiente.

 <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">

Lo que estoy tratando de capturar es lo siguiente, básicamente, desde la etiqueta <strong> en adelante hasta la línea que tiene BE . Puede ser insensible a mayúsculas y minúsculas.

 Some text 3</strong><br /> 2021-08-06 </div> <div><p> Some BE text 4.

Estoy usando /(?<=<strong>)[\s\S]*?b[ _\/,]?e[\W][\s\S]*?(?=<)/gim pero captura lo siguiente.

 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.

¿Qué estoy haciendo mal aquí?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sugiero una solución basada en DOM para iterar sobre los elementos div (en el nivel raíz). Luego, una simple prueba en el texto interno es suficiente para obtener la buena:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!