Regular Expressions 101

Community Patterns

homepage_finder

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 - 6 years ago