Url regex that can work without http://, https:// -
i using regex parse user's profile text , spit out links:
(https?:\/\/|www\.)[-a-za-z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-za-z0-9@:%_\+.~#?&\/\/=]*) how modified match common urls without http:// https://? (or if have better regex, that's fine)
e.g. matches:
twitch.tv/myusername youtube.com/myusername twitter.com/myusername steamcommunity.com/id/myusername will not match:
blah.blah for working example, noticed slack has url detector. 
update: 1 seems closer want still matches blah.blah
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
Comments
Post a Comment