Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)/?$
"
img

Description

this regexp will extract the homepage from an url; it will factor in the "www" if there is one, and it will accept a slash at the end

Submitted by anonymous - 7 years ago