Regular Expressions 101

Community Patterns

Community Library Entry

10

Regular Expression
Python

r"
(^https?://)?(\w+)?\.?(reddit\.com/|redd\.it/)(r/\w+/)?(comments/)?(\w+)
"
gm

Description

Simply searches for the thread-id in any kind of valid reddit-URL.

Submitted by Mio - 10 years ago