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

240
Views
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
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!