URL match checking and extraction with python regular expression Regex Full version

Personal notes

URL extraction discrimination almost perfect pattern

Regex is long, but I compared various things, but this is the most accurate. There are various patterns, but if there are many misunderstandings, problems will occur soon.

_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS

Recommended Posts

URL match checking and extraction with python regular expression Regex Full version
Regular expression manipulation with Python
String replacement with Python regular expression
Start / end match in python regular expression
Solve with Ruby, Perl, Java and Python AtCoder ABC 047 C Regular Expression
Understanding with mathematical formulas and Python LiNGAM (ICA version)
A python regular expression, or a memo of a match object
Version control of Node, Ruby and Python with anyenv
Regular expression with pymongo
python regular expression memo
URL shortening with Python
Regular expression in Python
Regular expression in Python
Check version with python
Get the matched string with a regular expression and reuse it when replacing on Python3
Determine if a string is a time with a python regular expression
Python regular expression basics and tips to learn from scratch
Installation procedure for Python and Ansible with a specific version
Get rid of dirty data with Python and regular expressions
[Python] A function that searches the entire string with a regular expression and retrieves all matching strings.
Programming with Python and Tkinter
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Python 處 處 regular expression Notes
Full bit search with Python
About Python and regular expressions
python with pyenv and venv
Specify python version with virtualenv
Works with Python and R
Speed comparison of Wiktionary full text processing with F # and Python
A python regular expression, str and unicode that are sober and addictive
Batch download images from a specific URL with python Modified version