注释
字符序列(?#标记开始一个注释直到遇到一个右括号。不允许嵌套括号。 注释中的字符不会作为模式的一部分参与匹配。
如果设置了 PCRE_EXTENDED 选项, 一个字符类外部的未转义的 # 字符就代表本行剩余部分为注释。

User Contributed Notes 1 note
asamaru at asamaru dot net ¶
5 years ago
<?php
$string = 'test';
echo preg_match('/te(?# comments)st/', $string) . "\n";
echo preg_match('/te#~~~~
st/', $string) . "\n";
echo preg_match('/te#~~~~
st/x', $string) . "\n";
// result
// 1
// 0
// 1
备份地址:http://www.lvesu.com/blog/php/regexp.reference.comments.php