zend框架2中的正则表达式输入过滤器

时间:2015-08-18 16:13:38

标签: regex zend-framework zend-framework2

我通过以下参数添加输入过滤器:

问题是为什么zend框架2有utf8模式的问题

  $formInputFilter->add($inputFactory->createInput(array(
                        'name' => $field->attribute->id,
                        'required' => true,
                        'validators' => array(

                            array(
                                'name' => 'Regex',
                                'options' => array(
                                    'pattern' => '/^[0-9,\x{0600}-\x{06FF}]*/u',
                                    'messages' => array(
                                        'regexNotMatch'=>'number is not correct'
                                    ),
                                ),
                            ),
                        ),
                    )
                )
                );

错误是:

preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 15

1 个答案:

答案 0 :(得分:1)

我在我的网址中使用此功能。它适用于任何数字和字符

'\/^\d{4},(?:\s|\w)+\/u*'

https://regex101.com/r/mW4xJ4/2

\/^\d(?:\s|\w)+\/u*

您可以在此处查看每个角色的说明:https://regex101.com/r/mW4xJ4/1