Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!