How do I extend this regex to match www.example.com in addition to http://example.com?
- by algorithmicCoder
I've got a regex for detecting links that works pretty well for urls of the form http://example.com, http://www.example.com etc but not for www.example.com
I am trying to extend what i have so that www.foo.com also gets matched without breaking previous functionality.
I tried this:
/\(?\b((http|https|ftp):\/\/|)(www\.)[-A-Za-z0-9+&@#\/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#\/%=~_()|]/
but this only works when www is present and doesn't work e.g. for http://example.com ...