dpuwov1487 2012-07-13 07:16
浏览 44
已采纳

Zend_Validator_Regex抛出错误:使用模式时出现内部错误

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.

  • 写回答

3条回答 默认 最新

  • doumindang2416 2012-07-13 07:33
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏