Search for links in a text string

I am in a situation where I have a line of source text where I want to find all the links (starting from Http://) and put <a href="thelink">before the link and then </a>after the link. The problem is that I do not know when the link ends. I.e:.

( http://www.mylink.com )

In the above example, I can find the start of the link: Http://but I don’t know when the link ends, so it will also take on value ).

Can anyone shed some light on this? Should I use some kind of RegEx pattern?

Thank you very much in advance.

All the best

Bo

+3
source share
1 answer

RegexBuddy

\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|]

<a href="\0">\0</a>

, URL- , , , .

, . , .

, , .

+3

Source: https://habr.com/ru/post/1729270/


All Articles