[英]php - Warning: filter_var() [function.filter-var]: Unknown modifier '+'
I am trying to use a regular expression from http://www.regular-expressions.info/email.html , specifically: 我正在尝试使用http://www.regular-expressions.info/email.html中的正则表达式,特别是:
[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 this 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. 但是,您应该真正使用
filter_var($email, FILTER_VALIDATE_EMAIL)
而不是推出自己的( 不正确的 )正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.