Instead of a regex you can use alpha_num.
To solve with a regex it will look something like this: 'regex:/[a-zA-Z0-9]+/', {1} has no limiting effect here it will just be added to the character group.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello,
Something is wrong with my regex in Laravel a username should only include uppercase letters, lowercase letters and numbers.
public function rules()
{
return [
'name' => [
'required',
'unique:users,name',
'min:10',
'regex:/[a-z{1}A-Z{1}0-9{1}]+/',
]
];
}
According to this site it actually should work: https://regexr.com/
hope you guys could help me again
thanks Amit
Please or to participate in this conversation.