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

235
Vistas
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 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