Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
^http(?:s)?://(?:www\.)?(?:[\w-]+?\.)?reddit.com(/r/|/user/)?(?(1)([\w:\.]{2,21}))(/comments/)?(?(3)(\w{5,9})(?:/[\w%\\\\-]+)?)?(?(4)/(\w{3,9}))?/?(\?)?(?(6)(\S+))?(\#)?(?(8)(\S+))?$
"
gm
Unit Tests
reddit.com
http
subdomain
incomplete subreddit
subreddit
two char subreddit should match
Too large subreddit
Incomplete post
Just post id
Incomplete post id
post id and title
subreddit name slash url params
post id url params
broken comment id
comment id
comment id slash
post title with space/%
user profile
url params test
URL without subreddit post id
URL without subreddit comment ID
URL with backslashes in title
Subreddit with 2 char name
www.np.reddit.com
http://en-us.reddit.com/r/fantasyfootbal…
→ capture group 5 equals
ceuq2ds
5 char thread id
# in link
: in sub name
First comment
7 char thread id