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

225
Vistas
How to convert some words in a sentence into a link?

This is an example of creating links in a string using react. Most of the examples I found were my manipulating dom so after so messing around I figured out how to do it.

function profile() {
  const hashtagRegex = /\B(\#[a-zA-Z]+\b)(?!;)/gm;
  const { fullName, userName, image, bio } = userProfileData;
  const bioMatch = bio && bio.match(hashtagRegex);
  const editbio = bio && bio.split(" ");
  bioMatch &&
    editbio.map((word, index) => {
      if (word.match(hashtagRegex)) {
        editbio[index - 1] = editbio[index - 1] + " ";
        editbio[index] = <a href="https://google.com">{word}</a>;
      } else {
        editbio[index] = " " + word;
      }
    });
  return (
    <div className="profile">{editbio}</div>
  );
}

If you add spacing directly to the array index it converts the link into [object][object] and if you try to join in the return it does the same so this worked for me. If someone has a better way to do it, please share.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The easiest way to link the website to the text if you are trying to do it with HTML would be

<p><a href="link">word</a></p>
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