$re = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
/m';
$str = 'frankp@gmail.com
shannon.eee@gmail.com
franks&shannon@gmail.com
frank%ddd@gmail.com
frank@gmail$.com
frank@gmail_gmail.com
frank@gmail.research.com
joe@ggg.gg.cccc.com
joe..joe@gmail.com
/
https://stackoverflow.com/questions/5174171/fix-regular-expression-for-emails-to-not-allow-consecutive-periods/5174201#5174201
*To avoid matching two consecutive dots you can add a negative lookahead at the beginning of your regular expression:
/^(?!.*\\.{2})[a-z0-9etc...
------------
It will fail to match if there are two consecutive periods anywhere in the string and it doesn\'t require any other modifications to your original regular expression.
However it seems a bad idea as your regular expression isn\'t correct in the first place. If you insist on using regular expressions to validate email addresses, try this:
*/
wilson..gmail.com
wilson.gmail.com
^(?!.*\\.{2})/[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php