It is necessary to remove from the variable all the characters that are there, but leave:

  • ordinary letters (a, b, c, d ...)
  • @ (dog)
  • . (point)

How to do this?

Or make a check. Those. if there is something else there, then do not. Those.

if (preg_match('выражение', $peremennaya)) { выполняем } else { нет } 
  • [actually your own question] [1] [1]: hashcode.ru/questions/75318/… - Artem
  • there is still a euro sign and many, many other signs (for example, Chinese letters) that are not recruited may be present and that option will be missed. In addition, who knows, maybe some more characters will add. - nick777
  • Here is another example: ♪ ◙. Thousands of such signs, if not more ... - nick777
  • so that's exactly what is easier to check for the desired value than to remove and check for unnecessary characters hemorrhoids and incorrect. If you check for everything, then this is not ice. - Artem
  • Yes, I understood and corrected. In addition, if you cut, then there in the porridge then the remaining text is formed and nothing can be done with it. It is necessary to check for compliance with the regular schedule, as written by timka_s. Thank. - nick777

2 answers 2

Replacement

 preg_replace( '/[^a-zA-Z@\.]/', '', $str ); 

or check:

 if ( preg_match( '/[^a-zA-Z@\.]/', $str ) ) die('symbol'); 

You can use this Re:

 /[^az@\.]/i 

And with UTF:

 /[^az@\.]/iu 

    Try using str_replace("[az][0-9]","",$peremenaya)

    • one
      az you also disappear, and they must be left - DemoS