Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些文字在
标签之类的
<p>This is text a</p><p>This is text ended without p</a>
我想使用正则表达式来匹配两个类并提取 InnerText:
const string patternDesp = @"<p>(.+?)(</p>|</a>)";
但是当我查看时m.Groups[1],它只返回 1 个匹配项。m.Groups[2]给我
m.Groups[1]
m.Groups[2]
</a>
我已经解决了这个问题,看来我需要使用MatchCollection而不是Match.
MatchCollection
Match