Skip to content

Instantly share code, notes, and snippets.

View GoudronViande24's full-sized avatar
💔
I loved her

Thomas Fournier GoudronViande24

💔
I loved her
View GitHub Profile
@GoudronViande24
GoudronViande24 / Regex Discord Tag Tutorial.md
Last active March 24, 2022 14:40 — forked from Xevshak/Regex Discord Tag Tutorial.md
A quick tutorial on regexs using discord tags as an example

Regex Discord Tag Tutorial

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.

Summary

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