Comment: Begin hostname isolation
Group hostname(?P<hostname>
# https://
(?P<protocol>(?:https?:)?\/\/)
# reddit.com or redd.it
(?P<subdomain>(?!about\.)[\w-]+?\.)?(?P<domain>[rc]edd(?:it\.com|\.it))
) Comment: https://
Group protocol(?P<protocol>(?:https?:)?\/\/) Non-Capturing Group(?:https?:)? ?repeats the group contents below at most once:
httpthe literal text http (case insensitive) s?optionally matches the literal s (11510 / 1638 / 7316) (case insensitive)
:the literal : (5810 / 728 / 3A16)
\/the literal / (4710 / 578 / 2F16)
\/the literal / (4710 / 578 / 2F16)
Comment: reddit.com or redd.it
Group subdomain(?P<subdomain>(?!about\.)[\w-]+?\.)? ?repeats the group contents below at most once:
Negative Lookahead(?!about\.) aboutthe literal text about (case insensitive) \.the literal . (4610 / 568 / 2E16)
+?matches at least one character from the set below:
\wa Unicode word character
-the literal - (4510 / 558 / 2D16)
\.the literal . (4610 / 568 / 2E16)
Group domain(?P<domain>[rc]edd(?:it\.com|\.it)) rthe literal r (11410 / 1628 / 7216) (case insensitive)
cthe literal c (9910 / 1438 / 6316) (case insensitive)
eddthe literal text edd (case insensitive) Non-Capturing Group(?:it\.com|\.it) itthe literal text it (case insensitive) \.the literal . (4610 / 568 / 2E16)
comthe literal text com (case insensitive) \.the literal . (4610 / 568 / 2E16)
itthe literal text it (case insensitive) Comment: End hostname isolation
Comment: Do not match any reserved URLs, like reddit.com/gold or reddit.com/advertising
Negative Lookahead(?!\/(?:blog|about|code|advertising|jobs|rules|wiki|contact|buttons|gold|page|help|prefs|user|message|widget)\b) \/the literal / (4710 / 578 / 2F16)
Non-Capturing Group(?:blog|about|code|advertising|jobs|rules|wiki|contact|buttons|gold|page|help|prefs|user|message|widget) blogthe literal text blog (case insensitive) aboutthe literal text about (case insensitive) codethe literal text code (case insensitive) 4th Alternativeadvertising advertisingthe literal text advertising (case insensitive) jobsthe literal text jobs (case insensitive) rulesthe literal text rules (case insensitive) wikithe literal text wiki (case insensitive) contactthe literal text contact (case insensitive) buttonsthe literal text buttons (case insensitive) goldthe literal text gold (case insensitive) \ba Unicode word boundary
Comment: URL path
Group subreddit(?P<subreddit>
# </r/subreddit>
(?:\/r\/[\w-]+\b(?<!\/pcmasterrace))
|
# </tb>
(?:\/tb)
)? Comment: </comments>/POSTID
Group comments(?P<comments>\/comments)?? Comment: Start the Post ID detection, and testing for whether or not it should match a shortlink
Group postID(?P<postID>\/\w{2,7}\b(?<!\/46ijrl)(?<!\/wiki)) Comment: Match rest of URL for debugging
Group everythingElse(?P<everythingElse>(?:(?!\))\S)*)