No, unforunately you have to validate by what's not in them. Start with obvious things you don't want like elephants, boats, and blue monkeys. 😉
Yes you can.
To check for an @ in a string do this
<?php
if(strpos($string,'@')) {
//string has an @
} else {
//string does not have an @
}
?>
However this does not check it very thoroughly. Prehapse you culd try something a little more. For an email, for example.
<?php
if(preg_match('/[a-zA-Z0-9-_\.]+@([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9]{2,4}/',$string)) {
//It's an email
} else {
//It's not an email
}
?>
the preg is saying the string can begin with 1 or more alpanumerics hyphens, underscores or dots then there must be an @ then there can be 1 or more groups of alphanumerics seperated by dots and ending in between 2 and 4 alphanumerics. If this is a string in itself (ie, not part of a larger string) you can place a caret () at the start and a ($) at the end. The caret at the start is the important one as this will speed the regex up considerably (not that it will be slow otherwise, but a little more speed is always nice 🙂)
HTH
Bubble