开发者

zend framework regex problem: "Internal error while using the pattern"

I've tested my regular expression on multiple testers and I've tried multiple regular expressions too but I keep getting the error: "Internal error while using the pattern '/^(04\d{2}/(\d{2} )\d{2} \d{2})$/'". I know it's probably not the best regex but I couldn't find a good one and I'm not really a pro at this and I have to move on. The phone numbers it should be matching are 04dd/dd dd dd with d being a number between 0 and 9. This is the code I'm using when creating the form.

$phone = $this->addElement('text', 'phone', array(
        'filters'    => array('StringTrim'),
        'validators' => array(
            array('regex', false, array('/^(04\d{2}/(\d{2} )\d{2} \d{2})$/'))
 开发者_高级运维       ),
        'required'   => true,
        'label'      => 'Phone:',
    ));

How can I solve this problem? Thanks already.


You have to escape the slash:

array('regex', false, array('/^(04\d{2}\/(\d{2} )\d{2} \d{2})$/'))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜