I have a comments
(string) field from backend API which contains long text and possible with URLs too. I want to render them as hyperlinks (anchor HTML tags).
The solution I have right now, is to perform string replace using regex, to convert all URLs in the text into tags. It's working fine.
But is there better/more holistic way to do this? Maybe some NPM package that have more features to render more than just URLs(hashtags, @user, etc)? Btw, I'm using react/angular most of the time, any JS recommendation is applicable.
Sample data:
Hello, My name is John.\n\nThis is my linkedin profile: https://linkedin.com/in/john .\n\nFollow me! Thanks.
Expected outcome:
Hello, My name is John.
This is my linkedin profile: <a href="https://linkedin.com/in/john">https://linkedin.com/in/john</a> .
Follow me! Thanks.