Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require at least one alpha character

We have a login form that allows you to enter in your user_id or your player_tag. We have a model with the following rules:

protected $rules = ['player_tag' => 'required|unique|min:3|max:15|regex:/^[a-zA-Z0-9_]+$/'];

Is there a way to add a rule that requires the player_tag field to contain at least 1 alpha character (a-zA-Z)?

like image 268
Get Off My Lawn Avatar asked Feb 22 '16 16:02

Get Off My Lawn


People also ask

What is an alpha character in password?

Passwords can contain alpha or numeric characters (No special characters). A password must begin with an alphabetic character. Passwords are a minimum of 5 characters and a maximum of 8 characters.

What is alpha character example?

An alphanumeric example are the characters a, H, 0, 5 and k. These characters are contrasted to non-alphanumeric ones, which are anything other than letters and numbers. Examples of non-alphanumeric numbers include &, $, @, -, %, *, and empty space.

What is an alpha character type?

“An Alpha is a leader; she is self-assured, powerful and confident in everything she does,” says Spencer. “These personality types don't hold back, tending to steer the pack in friendships and powerfully lead their teams in work.

What does 1 non-alphanumeric characters mean?

Non-alphanumeric characters are characters that are not numbers (0-9) or alphabetic characters. Alphabetic characters are defined as a-z, A-Z, and alphabetic characters in the Latin-1 code page 850.


1 Answers

This might help you:

^(?=.*[a-zA-Z]).+$

Here is a working example: https://regex101.com/r/gD3gR6/2

like image 124
Tim Hysniu Avatar answered Oct 28 '22 17:10

Tim Hysniu