Regular Expressions 101

Community Patterns

1...456

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