protected function getStrippedUrl($url) { $pattern = '/\\w+\\..{2,3}(?:\\..{2,3})?(?:$|(?=\\/))/i'; return preg_match($pattern, $url, $matches) === 1 ? $matches[0] : false; }