September 5, 2022


Program To Verify Username With Only Letters, Numbers And Underscore

Sunny Kumar

Program To Verify Username With Only Letters, Numbers And Underscore

This article will provide you with a way to check if a string contains alphanumeric characters with underscores. In other words, determine whether a string consists of only letters, numbers, underscore, and not any other character.

Regular Expressions are the best way to identify patterns within strings. They seem to be a bit difficult and irritating, but once you know how to use them, they're amazing!.

Basically, a regular expression is a pattern describing a certain amount of text. For example, we know that emails are always like:


If we want to describe the pattern of an email, we will say something like this: Starting with a username (a combination of letters and numbers), followed by an @ symbol, followed by the domain (another combination of letters and numbers) followed by the extension (that starts with a dot . followed by a combination of only letters).

The process of describing the pattern of an email is the same process you will follow when you want to create a regular expression. The only difference will be the syntax:


The regex you are looking for is:


The length restriction for example can be edited like this:


So you put in your /conf/config.php file:

$Configuration['Garden']['User']['ValidationRegex'] = '[A-z_]';

$Configuration['Garden']['User']['ValidationLength'] = '{4,15}';

Probably change the translation here too:

$Definition['UsernameError'] = "Username can only contain letters, numbers, and underscores, and must be between 4 and 15 characters long.";

What is HuggingChat? Everything you need to know about this open-source AI chatbot
A compact analysis of HuggingChat.
Rishika Shidling
MiniGPT-4: Open-Source Model for Complex Vision-Language Tasks Like GPT-4
A pithy outlook on MiniGPT-4: an open-source model for complex vision-language tasks like GPT-4
Rishika Shidling
AutoGPT vs BabyAGI
A concise comparison between AutoGPT and BabyAGI.
Rishika Shidling