[英]regex &align:%HORIZONTAL%|%VERTICAL%
I would like to have a regex that matches something like this: 我想有一个匹配这样的正则表达式:
&align:%HORIZONTAL%|%VERTICAL%
%HORIZONTAL% may be "left" or "right" or "center" %HORIZONTAL%可以是“左”或“右”或“中心”
%VERTICAL% may be "top" or "bottom" or "center" %VERTICAL%可能是“顶部”或“底部”或“中心”
I tried something like this: 我尝试过这样的事情:
&align:(left|right|center)\|(top|bottom|center)
And I got this: 我得到了:
Array(
[0] => &align:left|center
[1] => left
[2] => top
)
What would I have to change to get only one match at all? 我必须改变什么才能只得到一场比赛? The [1] and [2] must not be possible.
不能使用[1]和[2]。
Parentheses serve two purposes — grouping and capturing. 括号有两个目的-分组和捕获。 To get the grouping you want without capturing the matches, use
?:
: 要获取所需的分组而不捕获匹配项,请使用
?:
::
&align:(?:left|right|center)\|(?:top|bottom|center)
Manual reference: http://uk3.php.net/manual/en/regexp.reference.subpatterns.php 手册参考: http : //uk3.php.net/manual/en/regexp.reference.subpatterns.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.