try to make regular expression for mail but it not work
i want to remove all other special character or any char not allowed in email
so except 0-9 a-z A-Z - _ @
every other char must be removed .
$pass = preg_replace ('#[^a-z0-9-_.@]+#i', '', $_GET['e']);
echo $pass ;
if i try 33.php?e=frefr_-+_)(*&^%$#!@edef.fr
i get : " frefr_-_ "
and i must get : frefr_-_@edef.fr
and remove all other char from the email . thank you :)
i find it :P
$email = preg_replace ('#[^a-z0-9-_@.]+#i', '', $_GET['e']);
the "&" and "#" in the link was coused problem in testing .
This doesn't directly answer your question requesting "regex" but validating emails with regex is incredibly complicated and subject to potential maintenance as internet standards change.
List of valid emails and thus complex regex needed:
https://en.wikipedia.org/wiki/Email_address#Examples
Instead, I suggest you instead use the built in tools which will get updated along with PHP to save your having to do it.
FILTER_SANITIZE_EMAIL
Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
$filteredEmail = filter_var($fullEmail, FILTER_SANITIZE_EMAIL);
FILTER_VALIDATE_EMAIL
Validates whether the value is a valid e-mail address.In general, this validates e-mail addresses against the syntax in RFC 822, with the exceptions that comments and whitespace folding and dotless domain names are not supported.
$emailValid = filter_var($fullEmail, FILTER_VALIDATE_EMAIL);
This will return the email if valid, otherwise boolean false
which you can check against.