正则表达式查找特定变量

xinqq163 2010-07-01 03:53:41
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<$:title>
<$:content>
</body>
</html>

index.aspx
如何加载index.html

查找出
<$:title>
<$:content> 这些出来。
...全文
73 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinqq163 2010-07-01
  • 打赏
  • 举报
回复
怎么加在静态的还不知道 但知道匹配了 谢谢两位了
public void IsMatchDemo()
{
string source = "刘备<$:name>ABC关羽ABc<$:title>张飞Abc赵云abc诸葛亮aBC孙权abC周瑜AbC鲁肃aBc曹操许攸郭嘉需晃袁绍";
string str=@"<\$:[^<>]+>";
MatchCollection m1;
Regex re = new Regex(str);
m1=re.Matches(source);
for(int j = 0;j<m1.Count;j++)
{
HttpContext.Current.Response.Write(m1[j].Value+"<br>");
}

if (Regex.Match(source, str, RegexOptions.Compiled).Success)
{
HttpContext.Current.Response.Write("字符串中包含有敏感词:孙权!");
}
else {
HttpContext.Current.Response.Write("没有查找到!");
}
}
xinqq163 2010-07-01
  • 打赏
  • 举报
回复
能在说 如何在在静态文件吗。 循环显示查找的 谢谢
wackyboy 2010-07-01
  • 打赏
  • 举报
回复

"<\$:[^<>]+>"
skyland84 2010-07-01
  • 打赏
  • 举报
回复
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<\$:[a-z]+>");
System.Text.RegularExpressions.Match match = reg.Match(divLoginMain.InnerHtml);
Response.Write(match.Value);

62,073

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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