Regular Expressions 101

Find Reddit Threads

Open Workspace
  • Python
  • Match
12

Regular Expression

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