Regex for Discord Username
Regex Pattern
^[a-z0-9_.]{2,32}$Discord username (2-32 chars, lowercase alphanumeric with dots and underscores)
Quick Answer
The regex pattern for discord username is `^[a-z0-9_.]{2,32}$`. Discord username (2-32 chars, lowercase alphanumeric with dots and underscores). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| john_doe | ✓ Matches |
| user.name | ✓ Matches |
| player123 | ✓ Matches |
| a | ✗ No match |
| HAS-UPPER | ✗ No match |
| has space | ✗ No match |
| toolongusernameabcdefghijklmnopqrst | ✗ No match |
Code Examples
javascript
const regex = /^[a-z0-9_.]{2,32}$/;
const isValid = regex.test(value);python
import re
pattern = r'^[a-z0-9_.]{2,32}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^[a-z0-9_.]{2,32}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^[a-z0-9_.]{2,32}$/', $value)) {
echo "valid";
}java
String pattern = "^[a-z0-9_.]{2,32}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
UUID v4
UUID version 4 (randomly generated)
UUID (Any Version)
Any RFC 4122 UUID (versions 1-5)
JWT Token
JSON Web Token (header.payload.signature)
Hex String
Any-length hexadecimal string
Base64 String
Standard base64 encoded string
Alphanumeric Username
Username with letters, digits, underscores (3-16 chars)