[英]C# Regex expression matching multiple groups
I have some text in the 我有一些文字
tags such like 像这样的标签
<p>This is text a</p><p>This is text ended without p</a>
I want to use Regex to match both classes and extract InnerText: 我想使用Regex来匹配两个类并提取InnerText:
const string patternDesp = @"<p>(.+?)(</p>|</a>)";
But when I look at the m.Groups[1]
, it only returns 1 match. 但是当我看
m.Groups[1]
,它只返回1个匹配项。 m.Groups[2]
gives me m.Groups[2]
给了我
</a>
我已经解决了这个问题,似乎我需要使用MatchCollection
而不是Match
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.