PHP offers other subpattern modifiers.
php将提供其他子模式修饰词。
Another useful subpattern modifier is (? X).
另一个有用的子模式修饰词是(?x)。
It lets you embed whitespace in a subpattern, making the regex easier to read.
它允许您在子模式中嵌入空白,使regex更易读。
As shown in Figure 9, the Features section should now show the assigned subpattern for each feature.
如图9所示,Features部分现在应该显示分配给每个特性的子模式。
If you begin a subpattern with the modifier (? I), matching in the subpattern is case-insensitive.
如果子模式以修饰词(?i)为开头,则在子模式中进行匹配不区分大小写。
Go back to the features section, select the entry for longitude and click Add subpattern reference.
返回到features部分,选择longitude特性并单击addsubpattern reference。
This means "match a subpattern, but don't include the match in the back-references." So let's examine the subexpression
这表示“查找子模式的匹配字符串,但不包括反向引用中的匹配结果”。
Most of the time, you use a set of parentheses to define a subpattern and to capture the text that matches the subpattern.
在大多数情况下,使用一组括号可以定义子模式和捕捉匹配子模式的文本。
The first subpattern (Subpattern1) denotes the latitude (51 00 n) and the second sub-pattern (Subpattern2) denotes the longitude (9 00 e).
第一个子模式(Subpattern1)表示纬度(5100n),第二个子模式(Subpattern2)表示经度(9 00e)。
As with other PCRE implementations, you can refer to a subpattern match from within the replacement, allowing an operation to be self-referential.
正如其他PCRE实现一样,您可以从替换中引用子模式匹配,允许操作进行自引用。
Thus, the subpattern ((?x) edu | com | info) (notice the spaces between the alternation operators, added for legibility) is the same as (edu|com|info).
因而,子模式 ((?x)edu |com |info)(请注意备用操作符之间的空格,这些空格是为了易读性而添加的)与 (edu|com|info)相同。
Note that both the initial "minimal number of characters" subpattern and the operator subpattern are specified within capturing parentheses: \(...\).
注意,最初的 “最小字符数”子模式和运算符子模式都在捕捉圆括号内进行了指定:\(...\)。
Note that both the initial "minimal number of characters" subpattern and the operator subpattern are specified within capturing parentheses: \(...\).
注意,最初的 “最小字符数”子模式和运算符子模式都在捕捉圆括号内进行了指定:\(...\)。
应用推荐