Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
\/([0-9].*)\/([0-9].*)\/([0-9].*[^/])\/{0,}
/

Description

This regex captures the IDs in a message link in separate capture groups. Warning: Due to my personal use case, it doesn't care if it's a real Discord message URL. You can pretty easily add that yourself if you need it tho.

Capturing groups: Match 1: The whole ID string starting with / and may be ending with / Group 1: ID 1 (guild/server) Group 2: ID 2 (channel) Group 3: ID 3 (message)

Submitted by SIMPLE MARK - 2 years ago