gpt4 book ai didi

php -++ 和 **+ 是什么意思?

转载 作者:可可西里 更新时间:2023-10-31 22:09:27 25 4
gpt4 key购买 nike

我正在将一些库从 PHP 移植到 JavaScript,我遇到了这个正则表达式,它的某些部分我不清楚。

#(?: *+(?<= |^)\.((?:\([^)\n]++\)|\[[^\]\n]++\]|\{[^}\n]++\}|<>|>|=|<){1,4}?))#

不清楚的部分是

  1. *+
  2. ++

我知道,这个表达式应该接受像这样的字符串

.(title)[class]{style}<>
.[class]{style}<>
.[class](title){style}
// and so one - no metter of order \(.+\), \[.+\] and \{.+\} parts
// and optional <>, >, = or < at the end

此表达式与 PCRE_UNGREEDY 修饰符一起使用。

最佳答案

++

来自 What is double plus in regular expressions?

That's a Possessive Quantifier.

It basically means that if the regex engine fails matching later, it will not go back and try to undo the matches it made here. In most cases, it allows the engine to fail much faster, and can give you some control where you need it - which is very rare for most uses.

*+

*+* 量词的所有格量词。

关于php -++ 和 **+ 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17064108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com