Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda