REGEX for URL's


#1

HI Guys,

We are having a few issue with the regex that identifies URL’s in tweets. We had an issue in our application that when a user didnt include http or https it wouldn’t recognise as a link. We tried the below today and though it recognised the link now without http or https when we received a tweet whih started @: our application didnt like it. Are you please able to supply us with ‘regex’ that you use to identify URL’s?

((http|https|ftp)://)?[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(:[a-zA-Z0-9])?/?([a-zA-Z0-9-._?,’/\+&%$#!=~])[^.,)(\s]?

Lee


#2

Check out one of our twitter-text libraries, this one is for JS: https://github.com/twitter/twitter-text-js

You can find our process for identifying URLs there: https://github.com/twitter/twitter-text-js/blob/master/twitter-text.js


#3

Thank you so much for sharing this, something very time saving :slight_smile: