Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python validate url


django url validation regex (source):

import re
regex = re.compile(
        r'^(?:http|ftp)s?://' # http:// or https://
        r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?.)+(?:[A-Z]{2,6}.?|[A-Z0-9-]{2,}.?)|' #domain...
        r'localhost|' #localhost...
        r'd{1,3}.d{1,3}.d{1,3}.d{1,3})' # ...or ip
        r'(?::d+)?' # optional port
        r'(?:/?|[/?]S+)$', re.IGNORECASE)

print(re.match(regex, "http://www.example.com") is not None) # True
print(re.match(regex, "example.com") is not None)            # False
Comment

PREVIOUS NEXT
Code Example
Python :: python slice dictionary 
Python :: get absolute url django 
Python :: datetime date from string 
Python :: flask quickstart 
Python :: does jupyter notebook need internet 
Python :: how to fix Crypto.Cipher could not be resolved in python 
Python :: number of unique pairs in columns pandas 
Python :: Python pandas first and last element of column 
Python :: python cross validation 
Python :: pip install python-telegram-bot 
Python :: check if two strings are anagrams python 
Python :: delete database entry using name django 
Python :: python to run another code on timer while a separate code runs 
Python :: outliers removal 
Python :: difference between __str__ and __repr__ 
Python :: logging - multiple log file 
Python :: print all unique values in a dictionary 
Python :: django migrate not creating tables 
Python :: pandas group by day 
Python :: python get file name 
Python :: how to get key of a particular value in dictionary python using index 
Python :: pyspark dropna in one column 
Python :: models. type for phone number in django 
Python :: python how to make notepad 
Python :: Date Time split in python 
Python :: know datatype of pandas 
Python :: how to calculate z score in python 
Python :: matplotlib point labels 
Python :: python convert multidimensional array to one dimensional 
Python :: length of set python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =