Regular Expressions 101

Community Patterns

Discord name with both old and new name support

-1

Regular Expression
PCRE2 (PHP >=7.3)

/
^[^#]{2,32}#\d{3}[1-9]|(?!.*\.\.)[a-z\d_.]{2,32}
/
gm

Description

This discord regex supports both the new and the old version of discord names.

Old: NAME#[0001-9999]

  • Between 2 and 32 characters.
  • Any character except # is allowed

New: NAME

  • Between 2 and 32 characters.
  • Latin, lowercase letters are allowed (a-z)
  • All numbers are allowed. (0-9)
  • Underscores are allowed. (_)
  • Periods are allowed. (.)
    • You cannot have two consecutive period characters.
    • Ex: f.y.17 is allowed, while f.y..17 isn't.

Unlike many other discord regexes, this one does not allow the #0000 tag, and it does not allow having two consecutive period characters.

Submitted by Fy17 - 10 months ago