Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend_Validator_Regex throws error: Internal error while using the pattern

Message: Internal error while using the pattern "(http://)?(www.)?(youtu)((be.com)|(.be))/.*"

$element = new Zend_Form_Element_Text($this->name);
$element->setRequired(true)
        ->setLabel(FileTypes::$names[$this->fileType])
        ->setDescription('Paste YouTube link here')
        ->setDecorators(FormDecorators::$simpleElementDecorators)
        ->addValidator('regex', false, '(http://)?(www\.)?(youtu)((be\.com)|(\.be))/.*');

Throws error even with simple regular expression.

like image 418
divide by zero Avatar asked Sep 21 '26 08:09

divide by zero


1 Answers

Have you validated your regex as correct? Try it out in a regex tool, see if it generates any errors. A decent tool should tell you why your regex is wrong if it is invalid.

Most regexes I've seen are usually bookended with some kind of character, commonly '/'. The fact that yours isn't might have something to do with the error you're getting.

You should also bear in mind that whilst PHP's regex is similar to Perl, there are a few differences. They probably don't matter in this case, but you should be aware of them nonetheless. http://www.php.net/manual/en/reference.pcre.pattern.differences.php

like image 85
GordonM Avatar answered Sep 24 '26 03:09

GordonM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!