有一个号码的category property codes(参见部分“Unicode字符属性”),可被用于Perl-compatible Regular Expression (PCRE)如何使用类别属性代码从RegEx模式中排除字符?
我所定义的正则表达式模式(named subpattern),即应与字母(\p{L}
),数字(\p{N}
) ,空格分隔符(\p{Zs}
),也是标点符号(\p{P}
)。
(?<sport>[\p{L}\p{N}\p{Zs}\p{P}]*)
由于我使用URL进行路由,因此应该排除斜线。我怎样才能做到这一点?
编辑:
有关上下文Addtitional信息:用于Zend框架2模块中的路由定义的图案。
/Catalog/config/module.config.php
<?php
return array(
...
'router' => array(
'routes' => array(
...
'sport' => array(
'type' => 'MyNamespace\Mvc\Router\Http\UnicodeRegex',
'options' => array(
'regex' => '/catalog/(?<city>[\p{L}\p{Zs}]*)/(?<sport>[\p{L}\p{N}\p{Zs}\p{P}]*)',
'defaults' => array(
'controller' => 'Catalog\Controller\Catalog',
'action' => 'list-courses',
),
'spec' => '/catalog/%city%/%sport%',
),
'may_terminate' => true,
'child_routes' => array(
'courses' => array(
'type' => 'segment',
'options' => array(
'route' => '[/page/:page]',
'defaults' => array(
'controller' => 'Catalog\Controller\Catalog',
'action' => 'list-courses',
),
),
'may_terminate' => true,
),
)
),
),
),
...
);
您能否添加一些您想要应用正则表达式的字符串示例以及您想要的结果? – Alexey 2013-04-26 15:15:36
当然:“合气道”,“有氧运动,有氧运动”。 URI _can_在体育标题(例如'Aikido/page/2'或'Aerobic,Sportaerobic/page/2')之后继续,因此RegEx解析器应该通过斜线停止。 – automatix 2013-04-26 15:23:30