A Liberal, Accurate Regex Pattern for Matching URLs
Gruber attempts the impossible.
This pattern attempts to be practical. It makes no attempt to parse URLs according to any official specification. It isn’t limited to predefined URL protocols. It should be clever about things like parentheses and trailing punctuation.