Hey Artic,
to answer your first question, Zend_Validate_Regex uses the PCRE regex
engine (this one is about 200 times as fast as ereg, IIRC), which means that
all regexes must begin and end with a specific delimiter. You are free to
choose any character you like as delimiter, as long as it does not exist in
the regex itself.
This basically means that you will have to either put a backslash before all
the slashes inside your regex (you used the slash as regex delimiter), or
you will have to choose a character as delimiter that you did NOT use in
your regex (which will, looking at the regex, indeed be somewhat complicated
;)).
Or, as Darby already suggested, you could just use
Zend_Validate_EmailAddress as validator to make life easier.
Greets from Germany,
Tobias
2007/9/13, ArticSun <[EMAIL PROTECTED]>:
>
>
> Hi all!
>
> I got two questions about validating form data. The first one might be
> the simplest. I've got a regular expression which checks if an e-mail
> address is correct:
>
> new
>
> Zend_Validate_Regex("/^$|^[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*@(([a-z]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+([a-z]([-a-z0-9]*[a-z0-9]+)?){2,63}$/")
>
> I've added the / at the beginning and end because other expressions
> wouldn't
> work without it. This expression works when I use it in "ereg" for
> example.
> I now get the error: "Internal error matching pattern {the pattern}". Does
> anyone know what I'm doing wrong, or what would be a good expression (but
> I
> don't want to make this a script request!).
>
> The second question is about fields that get a <br /> when the value was
> not
> right regarding the validator. I do something like:
>
> // Apply the filter to the post data.
> $oFilter = new Zend_Filter_Input($aFilters, $aValidators,
> $this->_request->getPost(), $aOptions);
>
> // Save the data in the class var (escaped / html removed).
> $this->_aCheckedData['relation'] = $oFilter->getEscaped();
>
> When there are errors I show the form again. I try to print the data again
> (the data I put in _aCheckedData['relation'] here), and now the field that
> was not correct, contains "<br />", in stead of the value the user filled
> in.
>
> What could I be doing wrong here? If you need more information, please
> ask.
>
> Thanks!
> --
> View this message in context:
> http://www.nabble.com/E-mail-regular-expression-and-empty-fields.-tf4435743s16154.html#a12654897
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>