du skal bruge "non capturing" match ?:for at klare de ikke "http://" websteder
som
select
id,
substring(website from '(?:.*://)?(?:www\.)?([^/]*)')
as website_domain
from contacts
http://sqlfiddle.com/#!17/197fb/14
https://www.postgresql.org /docs/9.3/static/functions-matching.html#POSIX-ATOMS-TABLE