Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@pchc2005
pchc2005 / regex-weburl.py
Created September 20, 2018 09:47
A python port for regex-weburl.js by @dperini
import re
URL_REGEX = re.compile(
u"^"
# protocol identifier
u"(?:(?:(?:https?|ftp):)?//)"
# user:pass authentication
u"(?:\S+(?::\S*)?@)?"
u"(?:"
# IP address exclusion
# private & local networks