Regular Expressions 101

Community Patterns

Username Validation

1

Regular Expression
Python

r"
^(?=.{4,32}$)(?![_.-])(?!.*[_.]{2})[a-zA-Z0-9._-]+(?<![_.])$
"

Description

username is 4-32 characters long no _,- or . at the beginning no __ or . or . or .. or .- or _- inside no _,- or . at the end

^(?=.{4,32}$)(?![.-])(?!.*[.]{2})[a-zA-Z0-9.-]+(?<![.])$

Submitted by Rajesh Jayaswal - 8 years ago