我想文本两个标记之间的匹配/标签后面一看:如何使贪婪
-- #begin free text
this is the first bit of text I want to match
blah blah blah
this is the end of the matching text
-- #end free text
我设法与下面的.NET正则表达式来做到这一点
(?s)(?<=-- #begin free text\s*)(?<freeText>(.+?))(?=\s+-- #end free text)
相反以“这是......”开头的匹配,它与前面两个回车符相匹配,即“\ n \ n这就是...”
如何确保前面的回车符最多n个)不包括在内在比赛中?
供参考:新增说明。 :) – zx81
伟大的\ S做到了。我不得不修改你的正则表达式以包含组名:(?s)(?<= - #begin free text \ s *)(?(\ S。*?))(?= \ s + - #end免费文字) –
openshac
+1真的很好解释 – anubhava