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

79
Views
Regex obtiene texto entre las primeras etiquetas p

Estoy tratando de editar el código original para obtener la primera etiqueta p de product.description y probé el nuevo código, pero sin éxito. ¿Hay algún otro método que alguien pueda recomendar? Gracias de antemano por tu ayuda.

 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); }

Ejemplo de análisis de código nuevo:

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

Estoy tratando de agarrar todo lo que está dentro del primer párrafo solamente y necesito eliminar todas las etiquetas p y cualquier otra etiqueta posterior.

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

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);

Encontré una manera de orientar mi primer párrafo agregando un nombre de clase. Luego busco todas las etiquetas y las reemplazo con cadenas vacías.

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!