排名
6
文章
199
粉丝
4
评论
3
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

比如要获取一个这样标签的内容:<a>嘿嘿嘿</a>
代码如下:
- string summaryitem = "<a>嘿嘿嘿</a>";
- Match match = Regex.Match(summaryitem, "<a>(.*?)</a>");
- for (int i = 1; i < match.Groups.Count; i++)
- {
- Console.WriteLine(match.Groups[i].Value);
- }
如果要获取的字符串有多个,可以使用Matchs
- string summaryitem = "<font>嘿嘿嘿</font>sdfdsf<font>哈哈哈</font>";
- MatchCollection matchs = Regex.Matches(summaryitem, "<font>(.*?)</font>");
- foreach (Match match in matchs)
- {
- for (int i = 1; i < match.Groups.Count; i++)
- {
- Console.WriteLine(match.Groups[i].Value);
- }
- }
效果如下:
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价