Internal Error Matching Pattern Zend
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Zend_Validator_Regex throws error: Internal error while using the pattern up vote 3 down vote favorite 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. php regex zend-framework zend-validate share|improve this question edited Jul 25 '12 at 22:32 ByteNudger 96631527 asked Jul 13 '12 at 7:16 divide by zero 1,26421331 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepted 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
Resolved Fix version(s): - 1.10.7 (28/Jul/10) Reporter: Feighen Oosterbroek (noondaysun) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate Related issues: Attachments: Description Have created a form using the following element
$this->addElement("password", "pass_word", array( "label"=>"Password", "required"=>true, "validators"=>array( array("Regex", true, array("[a-zA-Z0-9~!@$%^&*]{5,15}")) ) )); I get the following error rendered in my browser "Internal error while using the pattern '[a-zA-Z0-9~!@$%^&*]{5,15}'" The regular expression matches correctly if I use a java pattern matching tool (Part of jEdit) I have tracked the fault back to Zend/Validate/Regex.php Line 107/** * Sets the pattern option * * @param string $pattern http://stackoverflow.com/questions/11465822/zend-validator-regex-throws-error-internal-error-while-using-the-pattern * @throws Zend_Validate_Exception if there is a fatal error in pattern matching * @return Zend_Validate_Regex Provides a fluent interface */ public function setPattern($pattern) { $this->_pattern = (string) $pattern; $status = @preg_match($this->_pattern, "Test"); **** This is line 107 **** if (false === $status) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'"); } return $this; } As you can see https://framework.zend.com/issues/browse/ZF-10201 the subject of preg_match will never pass my regular expression. I know that workarounds exist. I could daisy chain the regex validator with the stringLength validator or I could alter my regex Comments Posted by Hendri Smit (hendri.smit) on 2010-07-22T02:57:05.000+0000 Your regex pattern doesn't have any delimiters so it is invalid. That's why the exception is thrown. The preg_match function will only return false if the pattern is incorrect. It returns 0 if no match was found. This is not a bug. Read http://php.net/manual/en/book.pcre.php for more info on regular expressions in PHP. Posted by Feighen Oosterbroek (noondaysun) on 2010-07-23T03:32:01.000+0000 I know. I had posted the bug by the time I had realised why it was returning false, and couldn't find a way to resolve the bug myself Posted by Thomas Weidner (thomas) on 2010-07-24T06:43:41.000+0000 Closing as non issue according to the responses Posted by Thomas Weidner (thomas) on 2010-11-22T11:41:30.000+0000 Correct fix version as it has been deleted unintentionally by another user Overview ZF2 Issue Archive ZF1 Issue Archive Have you found an issue? Please report here! See the Overview section for more details. ReSign in Pricing Blog Support Search GitHub This repository Watch 69 Star 328 Fork 389 zendframework/zf1 Code https://github.com/zendframework/zf1/blob/master/library/Zend/Validate/Regex.php Issues 93 Pull requests 19 Projects 0 Wiki Pulse Graphs Permalink Branch: master Switch branches/tags Branches Tags master Nothing to show release-1.12.20 release-1.12.19 release-1.12.18 release-1.12.17 release-1.12.16 release-1.12.15 release-1.12.14 release-1.12.13 release-1.12.12 release-1.12.11 release-1.12.10 release-1.12.9 release-1.12.8 release-1.12.7 release-1.12.6 release-1.12.5 release-1.12.4 release-1.12.3 release-1.12.2 release-1.12.1 release-1.12.0 Nothing to show Find file Copy path zf1/library/Zend/Validate/Regex.php d58c384 Jan internal error 1, 2015 akrabat Update copyright to 2015. 2 contributors Users who have contributed to this file akrabat froschdesign Raw Blame History 147 lines (129 sloc) 3.85 KB "Invalid type given. String, integer or float expected", self::NOT_MATCH => "'%value%' does not match against pattern '%pat