Answers for "Regex to get reddit comment/submission ID from permalink"

0

Regex to get reddit comment/submission ID from permalink

// EX https://old.reddit.com/r/hardware/comments/nv4h5d/amd_announces_radeon_pro_w6800_and_w6600_rdna2/
// first capture group returns 'nv4h5d'
const SUBMISSION_URL_ID = /(?:^.+?)(?:reddit.com\/r)(?:\/[\w\d]+){2}(?:\/)([\w\d]*)/g;

// EX https://old.reddit.com/r/hardware/comments/nv4h5d/amd_announces_radeon_pro_w6800_and_w6600_rdna2/h11cohw/
// first capture group returns 'h11cohw'
const COMMENT_URL_ID = /(?:^.+?)(?:reddit.com\/r)(?:\/[\w\d]+){4}(?:\/)([\w\d]*)/g;
Posted by: Guest on June-09-2021

Code answers related to "Regex to get reddit comment/submission ID from permalink"

Browse Popular Code Answers by Language