InRegex Logo
InRegex
Nuovo

Match Valid Username in Javascript

Spiegazione

This regex pattern matches a valid username that consists of alphanumeric characters (both uppercase and lowercase), underscores, with a length between 5 and 20 characters.

Javascript

Espressione Regolare

^[a-zA-Z0-9_]{5,20}$
Copia
Javascript

Esempio di Utilizzo

const regex = /^[a-zA-Z0-9_]{5,20}$/; 
const username = 'john_doe123'; 
if (regex.test(username)) { 
    console.log('Valid username'); 
} else { 
    console.log('Invalid username'); 
}
Copia

Prova l'espressione

Espressioni Regolari Simili