VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > .net教程 >
  • ASP.net教程之cshtml中正则表达式使用后台代码

 //定义变量
bool a = false;
//正则表达式
string b = @" ^ (13[0 - 9] | 14[5 | 7] | 15[0 | 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9] | 18[0 | 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9])\d{ 8}
$";
//检查字符串与正则表达式是否匹配,结果赋值
//Regex需要引用using System.Text.RegularExpressions
//name是要输入的内容
a = Regex.IsMatch(name, b);
//不匹配
if (a == false)
{
Response.Write("<script>alert('失败')</script>");
}
//匹配
else
{
Response.Write("<script>alert('成功')</script>");
}
相关教程