Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE2 (PHP >=7.3)

/
^[^#]{2,32}#\d{4}$|^(?!.*\.\.|[A-Z])[a-z\d_.]{2,32}$
/
gm

Description

Accomodate for Discord's username changeover and match against either the old username or the new username. But only one or the other.

Match: CesarHvl#9000 cesarhvl cesar.hvl cesar_hvl

No Match: Cesar#Hvl#9000 CesarHvl#90001 CesarHvl c cesarhvllllllllllllllllllllllllll cesar..hvl cesarhvlCesarHvl#9000 (^^*(&)

Submitted by cesarhvl - a year ago