jeudi 2 mars 2023

Validate email containing special characters in Laravel [duplicate]

I am trying to validate email id which shouldn't contain some special characters using regex. There are other answers on stack overflow and i have taken this regex looking at those answers but it doesn't work.

I have tried different format of regex but none of them doesn't look to be a perfect fit or does not work.

For example, users must not register containing following special characters. *, !, #, $, &, \, ", '.

Following is the regex i am using but getting an error. I tries with other formats as well.

'email' => [
    'required', 
    'email',
    'unique:users',
    "regex:/^([^\"!'#\$\*\\]*)$/"
]

For this getting an error: preg_match(): Compilation failed: missing terminating ] for character class at offset 16

Not good at regex so if any one can give some inputs to resolve the issue.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire