You can do the following:
<?php // Email $pattern = '/^[\w\d_.+-]+@[\w\d-]+.[\w]+$/'; $str = 'info@domain.com'; if(preg_match($pattern, $str)) echo 'Валидно<br />'; else echo 'Не валидно<br />'; // Login $pattern = '/^[az\d]+$/i'; $str = 'login432'; if(preg_match($pattern, $str)) echo 'Валидно<br />'; else echo 'Не валидно<br />';
It should be taken into account that the regular expression for the email address is approximate, it is rather difficult to take into account all the nuances of the email (it will be possible to skip some exotic cases).