+ 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
3 Respostas
+ 2
alright guys, thanks alot i got it...am current using regex, it support http,https,ftp,ftps but not www
+ 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)
+ 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)