dougan4884 2012-06-20 11:01
浏览 30
已采纳

PHP preg正则表达式模式

  1. What does this pattern '/\\\(?!&#|\?#)/' match in PHP preg_replace function?
  2. Is this pattern valid?
  3. Why there are 3 backslashes in a row \\\?
  • 写回答

1条回答 默认 最新

  • doyhq66282 2012-06-20 11:12
    关注
    1. The pattern checks for a literal backslash not followed by &# or ?#.
    2. Yes.
    3. Because it's written as a PHP string literal. '\\' (an escaped escape character) in a string literal resolves to the actual string '\', so the actual regular expression is /\\(?!&#|\?#)/. The backslash is escaped inside the regex so it does not escape the (. So the actual pattern looked for is \&# or \?#.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?