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

82
Vistas
Regex get text between first p tags

I'm trying to edit the Original code to get the first p tag from product.description and tried the New Code, but with no success. Is there another method anyone can recommend? Thanks in advance for your help.

Original Code:
if (quickview.find('.des').length > 0) {          
  var description = product.description.replace(/(<([^>]+)>)/ig, "");
  quickview.find('.des').text(description);
}

New Code:
if (quickview.find('.des').length > 0) {
    var description = product.description.match(/<p>(.*?)<\/p>/g, "");
    quickview.find('.des').text(description);
}

Example parse for New Code:

<p>First inner content needed.</p> <p>content...</p> <span>content...</span>

I'm trying to grab everything inside the first paragraph only and need to remove all p tags and any other tags after.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if (quickview.find('.des').length > 0) {                    
  var description = product.description.match(/<p class="desQuickView">(.*?)<\/p>/g, "").map(function(val){
       return val.replace(/(<([^>]+)>)/ig, "");
  });
  quickview.find('.des').text(description);

I found a way to target my first paragraph by adding a class name. Then I look for all tags and replaced them with an empty strings.

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