I am trying to use a regular expression from http://www.regular-expressions.info/email.html, specifically:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
However when using th开发者_如何学Gois along with:
filter_var($email, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>$pattern)))
It brings up the error:
Warning: filter_var() [function.filter-var]: Unknown modifier '+'
Does anyone know how to fix this?
Your regexp is missing delimiters. Inserting, say, a semicolon before and after the pattern will fix this.
However, you should really use filter_var($email, FILTER_VALIDATE_EMAIL)
instead of rolling out your own (incorrect) regexp.
精彩评论