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

199
Vistas
regex, replace all matches but once

let me explain my problem, i have this code so far:

post.contentHtml().replace(/<\/?[^>]+(>|$)/g, '📷')

that strip ALL html tag from the output and replace with '📷'.

Now the problem is that a post can contain multiple tag, so if someone post an image or embed like:

<p><iframe data-s9e-mediaembed="twitter" allow="au…t:250px;max-width:550px;width:100%"></iframe></p>

the result is this: 📷📷📷📷📷

what i'm want to achieve is to show only ONE icon per element, or simply 1 icon. Is that possible

post.contentHtml output is:

ContentHtml: '<p><iframe data-s9e-mediaembed="twitter" allow="au…t:250px;max-width:550px;width:100%"></iframe></p>'
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Quantify the regular expression so it will match multiple times in a row.

post.contentHtml().replace(/(<\/?[^>]+(>|$))+/g, '📷')

pattern+ matches a sequence of 1 or more matches of pattern

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