正则表达式 怎么样提取标签里的内容

lan2312286 2010-07-27 04:43:29
怎么样将ul标签里的内溶提取(有嵌套)
...全文
196 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
longhair9711 2010-07-27
  • 打赏
  • 举报
回复
看不懂。。。。。都是高手啊
zjx198934 2010-07-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyazhe 的回复:]
try

C# code
Regex regExp = new Regex(@"(?isx)<ul[^>]*>(?><ul[^>]*>(?<o>)|</ul>(?<-o>)|(?:(?!</?ul\b).)*)*(?(o)(?!))</ul>");
MatchCollection mc = regExp.Matches(htmlcode)
foreach(Match m in mc)
……
[/Quote]
速度之快 太厉害了 逍遥!
healer_kx 2010-07-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyazhe 的回复:]

try
C# code
Regex regExp = new Regex(@"(?isx)<ul[^>]*>(?><ul[^>]*>(?<o>)|</ul>(?<-o>)|(?:(?!</?ul\b).)*)*(?(o)(?!))</ul>");
MatchCollection mc = regExp.Matches(htmlcode)
foreach(Match m in mc)
{
……
[/Quote]

up
!!```
兔子-顾问 2010-07-27
  • 打赏
  • 举报
回复
try
Regex regExp = new Regex(@"(?isx)<ul[^>]*>(?><ul[^>]*>(?<o>)|</ul>(?<-o>)|(?:(?!</?ul\b).)*)*(?(o)(?!))</ul>");
MatchCollection mc = regExp.Matches(htmlcode)
foreach(Match m in mc)
{
m.Value;//这就是ul段
}

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧