Detecting Link | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Detecting Link

Hello guys, am currently working on a php networking site, where user can share post like facebook. Now i want to detect link in user input for example if a posted "hello guys check out https://google.com" i want it to mark it as a link while fetching it out. Thanks in anticipation guys

29th Nov 2018, 10:06 PM
Asaølu Elïjah
Asaølu Elïjah - avatar
3 Answers
+ 2
alright guys, thanks alot i got it...am current using regex, it support http,https,ftp,ftps but not www
2nd Dec 2018, 1:10 PM
Asaølu Elïjah
Asaølu Elïjah - avatar
+ 1
That's harder than you would think, because https://نطاق.السعودية is a totally valid link for example! Anyway if you want to just focus on the latin alphabet and do it yourself, you can do it using regex. People on Sololearn have written lessons about that so make sure to check them out! (In php that would be the preg_match and other preg_* functions)
30th Nov 2018, 12:03 AM
Schindlabua
Schindlabua - avatar
+ 1
You can use regex for detecting part of string which begins with http. It will ne easier if you let a space after the link, because the regex will works better. (you can automatically add a space at the end of the text using php)
30th Nov 2018, 5:53 AM
Αητοιπe
Αητοιπe - avatar