/
(?(DEFINE)
(?<protocol> (?<=^|[^a-z]) [a-z]+? : )
(?<domain> (?:[a-z\-]+\.)+[a-z\-]+ )
(?<ip> (?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) )
(?<port> (?<!\s):\d+(?=\/|$|\s))
(?<pathquery>[A-Za-z\d\!\*\(\)\;\:\@\&\=\+\$\,\/\?\#\[\]\%\{\}\|\\\^\`\~]+)
(?<url> (?&protocol) (?: (?:\/\/) (?: (?&domain) | (?&ip) )