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

236
Visualizações
Unable to Detect link from Text with multiple links in text React js

I had tried to get the link from the text using below code

  urlify(description) {
   const regex = /(.+)\[(.+)\]\((.+)\)/;
   return description.replace(regex, (match, a, b, c) => {
    const text = `${a[0].toUpperCase()}${a.substring(1)}${b}`;
    return a+' '+`<a href="${c}" target="_blank">${b}</a>`;
   });
  }
  render() {
    let description='Hello this is [XYZ](wwww.XYZ.com) and please redirect to [PQR] 
     (www.PQR.com)'
     return (
     <p dangerouslySetInnerHTML={{__html: this.urlify(description),}}></p>
   );
  }
}

The output I get here is like

Hello this is XYZ and please redirect to PQR Only the last link is getting as required, I am trying something like 'Hello this is XYZ and please redirect to PQR' where XYZ and PQR should only act as link and (wwww.XYZ.com), (www.PQR.com) such link should act as href only.

about 4 years ago · Juan Pablo Isaza
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