I'm building a form in Zend Forms and get the following error while trying to add email validation regex:
Internal error while using the pattern
The code is:
$email->setLabel('Email:')
->setRequired()
->addValidator(new Zend_Validate_Regex('/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$/i'))
->addValidator(new Zend_Validate_StringLength(array(3, 255)))
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
This regex should validate correct email address and it works in other places (eg in JS).
I tried to remove i
option and to replace \\
with \\\\
but neither works. Any ideas?
缺少右括号(大概在最后一个?
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.