Regular Expressions 101

Community Patterns

123...6

Community Library Entry

12

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