【发布时间】:2010-06-22 11:55:52
【问题描述】:
我在 C# 程序中有以下正则表达式,但难以理解:
(?<=#)[^#]+(?=#)
我会把它分解成我认为我理解的:
(?<=#) a group, matching a hash. what's `?<=`?
[^#]+ one or more non-hashes (used to achieve non-greediness)
(?=#) another group, matching a hash. what's the `?=`?
所以我遇到的问题是?<= 和?< 部分。通过阅读 MSDN,?<name> 用于命名组,但在这种情况下,尖括号永远不会闭合。
我在文档中找不到?=,而且搜索起来真的很困难,因为搜索引擎大多会忽略那些特殊字符。
【问题讨论】:
-
查看此内容以了解有关环视的说明stackoverflow.com/questions/2973436/…
标签: regex lookahead lookbehind lookaround