Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
^(?P<protocol>[\w]+)\:\/\/(?P<host>[\w\.\-]+)(\:(?P<port>\d+))?((?P<path>\/[^\?\#\n]*)(\?(?P<params>(?P<first_param>[^\#\?\&\=\n]+(=[^\#\?\&\=\n]*)*)(\&(?P<param_more>[^\#\?\&\=\n]+(=[^\#\?\&\=\n]*)*))*))?(\#(?P<tag>[^\#\?\n]+)?)?)?$
"
gmi

Description

A simple python url matcher matching protocol, host, port, path, params, tag

Submitted by xinbenlv - 6 years ago