Community Patterns

Community Library Entry

1

Regular Expression
Created·2015-04-21 16:35
Flavor·Python

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

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