Regular Expressions 101

Community Patterns

1...45678...902

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