Summer Sale! All accounts are 50% off this week.

jewelhuq's avatar

Need help regarding validation (Allow A-Z,0-9,_,@,.)

How can we write a regular expression that should only allow character, number, dot and @

Now our rules is as follow

'username' => 'required|unique:users|alpha_num|min:4|max:50',

How can we change it ?

0 likes
3 replies
jewelhuq's avatar

I think I found the solution: 'username' => ['required','unique:users','min:4','max:50','regex:/^[A-Za-z0-9.@+]*$/'],

https://regexr.com/ is a good tools for regular express test

Please or to participate in this conversation.