Regex for parsing subreddit, IDs, and URL params out of a Reddit URL. Battle-hardened and tested for over three years on Reddit bots GifReversingBot, vredditshare, and switcharoohelper.
Returns the following information if it is exists in a Reddit URL
- /r/ or /user/ depending on whether this is in a sub or a user page
 
- subreddit name
 
- /comments/ if this is a comments page (mostly useless, just needed to do subsequent captures)
 
- Submission ID
 
- Comment ID
 
- ? if there are URL parameters
 
- URL Parameters (you'll need to parse them through something else to get keys and values)