C# Can';t摆脱非捕获正则表达式组

C# Can';t摆脱非捕获正则表达式组,c#,html,.net,regex,C#,Html,.net,Regex,我有以下字符串: In order to take this course, you must:<br> <br> &radic; &nbsp; &nbsp;Have access to a computer.<br> <br> &radic; &nbsp; &nbsp;Have continuous broadband Internet access.<br> <br> &a

我有以下字符串:

In order to take this course, you must:<br>
<br>
&radic; &nbsp; &nbsp;Have access to a computer.<br>
<br>
&radic; &nbsp; &nbsp;Have continuous broadband Internet access.<br>
<br>
&radic; &nbsp; &nbsp;Have the ability/permission to install plug-ins (e.g. Adobe Reader or Flash) and software.<br>
<br>
&radic; &nbsp; &nbsp;Have the ability to download and save files and documents to a computer.<br>
<br>
&radic; &nbsp; &nbsp;Have the ability to open Microsoft file and documents (.doc, .ppt, .xls, etc.).<br>
<br>
&radic; &nbsp; &nbsp;Be competent in the English language.<br>
<br>
&radic; &nbsp; &nbsp;Have access to a relational database management system.&nbsp; A good open-source option is MySQL (<a href="http://dev.mysql.com" target="_blank">dev.mysql.com</a>).<br>
<br>
&radic; &nbsp; &nbsp;Have completed the Discrete Structures course.<br>
<br>
&radic;&nbsp;&nbsp;&nbsp; Have read the Student Handbook.
要参加本课程,您必须:

&放射状;可以访问计算机。

&放射状;拥有连续宽带互联网接入。

&放射状;具有安装插件(如Adobe Reader或Flash)和软件的能力/权限。

&放射状;能够将文件和文档下载并保存到计算机。

&放射状;能够打开Microsoft文件和文档(.doc、.ppt、.xls等)。

&放射状;能熟练使用英语。

&放射状;可以访问关系数据库管理系统。一个好的开源选项是MySQL()。

&放射状;已完成离散结构课程。

&放射状;我读过学生手册。

我试图选择中间的文本(不包括标题、编码空间和<代码>
<代码> s),例如,第一个匹配应该是:<代码>可以访问计算机。< /代码>

我试过以下两种方法,但都不管用

这一行选择了整行:
^(?:&radic;([())\s]*)(*)((?:(\)*)$
,我试图调用
Regex.Matches(requirements.InnerHtml,RequirementsExtractorRegex,RegexOptions.Multiline)[0]。捕获[0]。值
,下面是值:
&radic;可以访问计算机。


这一个没有选择任何东西:
^(?对正则表达式稍加修改就会产生(几乎,见下文)所需的结果

^(?:&radic;(?:&nbsp;|\s)*)(.*)(?:<br/?>)
在启用多行匹配选项的情况下测试

警告


由于非可选的br元素,正则表达式匹配除最后一个之外的所有目标事件。量化该部分包括匹配中的最后一个事件,但使捕获组#1包含终止行的br元素-贪婪通用匹配覆盖。添加行终止锚定会阻止匹配(虽然在我对规范的理解中,这不应该——也许是测试环境的产物?)

你的意思是,除了使用正则表达式解析HTML之外,你还做错了什么?当然,你看到了“”?它与上一条语句不匹配。我认为
(?:|\s)*
代表
或空白,零次或多次,顺序不重要,不是吗?然后用什么来寻找重复零次或多次的可选单词?两个观察结果都是正确的,语法也正确。问题不在于第二个非捕获组,而在于第三个:a它阻止最后一行的匹配;当使用
*
查询时,前面的贪婪捕获组在每次匹配中获胜(即包含

)。我没有解决这个问题的方法(除了在原始字符串中人为添加

\n
)。我试图更改点,但仍然不起作用,请看一个。html实体的符号尚未进入regexr模式行,您必须在字符类中至少包含
。如果您这样做,并将
作为符号的替代,您将得到
^(?.radic;(?:.nbsp;|\s)*([a-Za z0-9.*)(?:)
匹配了4次。我最终使用了我的原始查询,排除了最后一个组,并从每个结果匹配中手动替换它。
Regex.Matches(requirements.InnerHtml, RequirementsExtractorRegex, RegexOptions.Multiline)[0].Groups[1].Value