• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • 注释

    字符序列(?#标记开始一个注释直到遇到一个右括号。不允许嵌套括号。 注释中的字符不会作为模式的一部分参与匹配。

    如果设置了 PCRE_EXTENDED 选项, 一个字符类外部的未转义的 # 字符就代表本行剩余部分为注释。

    <?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

    上篇:递归模式

    下篇:性能