更新时间:2023-02-22 13:52:48
我建议使用
:[^:\s]*(?:::[^:\s]*)*:
请参见 regex de mo 。它与 :(?:[^:\s] | ::)*:
,但效率更高一些,因为(?:.. | ...)*
部分是展开。
See the regex demo. It is the same pattern as :(?:[^:\s]|::)*:
, but a bit more efficient because the (?:..|...)*
part is unrolled.
详细信息
:
-冒号 [^:\s] *
-除以外的0多个字符:
和空格(?:
-一个未捕获的量化组的开始: ::
-双冒号 [^:\s ] *
-除:
和空格:
- a colon[^:\s]*
- 0+ chars other than :
and whitespace(?:
- start of a quantified non-capturing group:
::
- double colon[^:\s]*
- 0+ chars other than :
and whitespace