DD
DevDash

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

InputResult
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"
end

php

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

Want API access + no ads? Pro coming soon.