- What does this pattern
'/\\\(?!&#|\?#)/'
match in PHP preg_replace function? - Is this pattern valid?
- Why there are 3 backslashes in a row
\\\
?

PHP preg正则表达式模式
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- doyhq66282 2012-06-20 11:12关注
- The pattern checks for a literal backslash not followed by
&#
or?#
. - Yes.
- 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\?#
.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 - The pattern checks for a literal backslash not followed by