Community Patterns

Community Library Entry

11

Regular Expression
Created·2016-04-08 13:05
Flavor·Python

r"
^(http://|https://|http://www\.|https://www\.|www\.)?(www\.(twanda))?(([\w\-]+)?\.?(twanda|))(\.ch|\.com)(:\d+)?/.+$
"
igm
Open regex in editor

Description

This regex should extract the subdomain, if any, or the domain, if no subdomain is used, from an arbitrary URL

Submitted by trevi@twanda.com