Regular Expressions 101

Discord URL matching

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

/
https?:\/\/(cdn\.|media\.|)discord(app)?\.(com|net)\/(?:attachments\/(\d+)\/(\d+)\/([^\s?]+)(\?[^\s]+)?|users\/\d+|channels\/(\d+)(?:\/(\d+)){0,2})
/
g

Description

match every type of discord url with each useful part in a group pretty optimized, shouldnt be too harsh on your system

should work in every flavor except rust because rust sucks lol

Submitted by User9684