Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Python

r"
^((?:http(?:s)?:\/\/)?)((?:www\.)?[a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b)((?:\:\d+)?)((?:[-\w@:%\+.~#&/=]*)?)((?:\?[-\w%\+.~#&=]*)?)$
"
img

Description

Validates a URL input as text and then slices it into: protocol, base_url, port, relative_url and parameters. (Multiline and global flags are set for debugging reasons only)

Submitted by George Shazkho - 10 years ago