This is going to be a tutorial for making a Regular Expression (Regex) that can search text to find test that fits the format required for Discord usernames. Regexs are very powerful tools for making specific searches in text. Unlike if statements, it is much more condensed, and runs very quickly. The primary downside to Regex over normal logic is the lack of readability.
The Regex we will be using today is
/^.{3,32}#[0-9]{4}$/
This Regex allows between 3 and 32 of any character before a # symbol, and then checks for 4 numbers afterwards. Discord usernames follow this format. Some examples would be