Regular Expressions 101

Community Patterns

Community Library Entry

4

Regular Expression
Python

r"
(^(http|https):\/\/)?(i\.)?imgur.com\/((?P<gallery>gallery\/)(?P<galleryid>\w+)|(?P<album>a\/)(?P<albumid>\w+)#?)?(?P<imgid>\w*)
"
gm

Description

This regex grabs all kinds of imgur links and groups them in meaningful names aswell. This way you have full flow-control in your python-scripts.

Submitted by Mio - 10 years ago