How to build links to users on the website?

The site includes a chat, you need to make it so that if a person sent a link to something, it is immediately transformed in a real clickable link that you can go.

Give an example of VK, if there is a send link, it is converted to a clickable link.

Thank you!

P. S. Sory, MB the solution is simple, I just can't formulate a question or a request to Google...
March 19th 20 at 08:59
3 answers
March 19th 20 at 09:01
Solution
HTML:
<span class="message">text http://example.com text</span>

JS:
var message = document.querySelector('.message');
message.innerHTML = message.innerHTML.replace(/(https?:\/\/\S*)/g, '<a href="$1" target="_blank">$1</a>');
March 19th 20 at 09:03
Solution
Check regular expression
March 19th 20 at 09:05
Solution
where there is a message, do the inspection, for example, if a word starts with http:// or https:// then record it in a variable and replace
<a href="variable value">value variable</a>
I will not say how to do it, because they do not know what you have for chat, but something like this. or you can implement it in where the message is sent/received by the server

Find more questions by tags HTML