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 (e.g. in JS).
I tried to remove i option and to replace \ with \\ but neither works. Any ideas?
Missing closing parenthesis (presumably after the final
?)