Thor
Honorary Master
- Joined
- Jun 5, 2014
- Messages
- 44,236
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 = "nobody@nowhere.co.za";
// 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 />";
}
?>