Regular Expressions 101

Community Library

Community Library Entry

11

Regular ExpressionOpen Workspace

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

Description
Created·2016-04-08 13:05
Type·Substitution
Flavor·Python

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
Open Workspace