Hypothetically,
Which one is faster in this specific example? I love regular expressions to bits, but just curious whether they should be used ALL the time.
Which one is faster in this specific example? I love regular expressions to bits, but just curious whether they should be used ALL the time.
PHP:
<php
$value = "[email protected]";
// preg_match is most flexible I know
if (!preg_match("/@/", $value)) {
echo "Validation failed.<br />";
}
// strpos vs preg_match from a performance perspective?
if (strpos($value, "@") === false) {
echo "Validation failed.<br />";
}
?>