📜  正则表达式从永久链接获取 reddit 评论提交 ID - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:51.350000             🧑  作者: Mango

代码示例1
// 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;