Gruber URL Regex tweak to capture "domain.com"
- by mootymoots
I found an updated version of John Gruber's regex for url matching in this post by user GianPac, which states it's been adapted to recognize url without protocol or the www part:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/?)(?:[^\s()<]+|(([^\s()<]+|(([^\s()<]+)))))(?:(([^\s()<]+|(([^\s()<]+))))|[^\s`!()[]{};:'\".,<?«»“”‘’]))
Whilst this works in most cases, I found it does not match "google.com". It does match "google.comm" and "google.co.uk", so this must be a small oversight.
The trouble is, I literally hate regex. It's the bane of my life. I just want to try and tweak this one more time to allow for "google.com" - can anyone throw me a pointer? I (think) it's something to do with this part of the code:
+[.][a-z]{2,4}/?)
?