If you ever have to work with Tweets, then twitter-text-js
will surely come in handy:
A JavaScript utility that provides text processing routines for Tweets. The library provides autolinking and extraction for URLs, usernames, lists, and hashtags.
The following snippet for example will autolink the hashtag and the mentioned username:
twitter.autoLink(twitter.htmlEscape('#hello < @world >'))
Installation per NPM/Yarn:
npm install twitter-text