请问匹配 http://www.company.com/news100.htm 的正则表达式如何写?

ofaint 2004-08-04 09:52:59
主要是如何处理转义符以及如何使用@,谢谢!
...全文
125 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lucky_GuoGuo 2004-11-05
  • 打赏
  • 举报
回复
可以考虑用Escape
string newStr;
string s="http://www.company.com/news100.htm";
newStr=Regex.Escape(s);
Regex r=new Regex (newStr);
if (r.IsMatch(s)==true)
//成功;
else
//不成功;
luckljtchinaren 2004-08-08
  • 打赏
  • 举报
回复
string myStr = 你所取得的网址;(如http://www.company.com/news100.htm )
if( Regex.IsMatch( myStr, @"^(http://www\.company\.com/news100\.htm)$")==true )
//匹配成功;
else
//匹配不成功;
sandsboy 2004-08-04
  • 打赏
  • 举报
回复
string text=@"bsahttp://www.company.com/news100.htmabc";
string patternString="http://www\.company\.com/news100\.htm"
MatchCollection matchs=Regex.Matchs(text,pattern,RegexOptions.IgnoreCase);

110,536

社区成员

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

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

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