匹配数字~

牛牛牛牛牛牛牛牛88 2009-04-17 05:44:49
<td bgColor=#fffff8>1</td>,匹配1,正则怎么写啊?\d连8也匹配进去了!

~(^@^)~
...全文
80 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuhq030710914 2009-04-17
  • 打赏
  • 举报
回复
(?<=\>)\d+(?=\<)
wuyq11 2009-04-17
  • 打赏
  • 举报
回复
@"(?<=\>)\d{1}[1]\w*(?=\<)
swl401 2009-04-17
  • 打赏
  • 举报
回复
这样就OK了吧:/1/
/\d/是匹配所有的数字
kkun_3yue3 2009-04-17
  • 打赏
  • 举报
回复
            string result = string.Empty;
string str = "<td bgColor=#fffff8>1 </td>";
Regex r = new Regex( @"(?<=\>)\d+|\w*(?=\<)" );
foreach( Match item in r.Matches( str ) ) {
result += item.Value + Environment.NewLine;
}

MessageBox.Show( result );
kkun_3yue3 2009-04-17
  • 打赏
  • 举报
回复
(?<=\>)\d+|\w*(?=\<)

111,126

社区成员

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

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

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