我在网上找了个判断EMAIL的正则表达式
也不知道什么意思就直接用了,但我输入了正确的它也说不正确
有谁能解释下这个正则表达式的意思吗?public bool IsEMail(string str)
{
Regex rx = new Regex(@"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*");
return rx.IsMatch(str);
}
也不知道什么意思就直接用了,但我输入了正确的它也说不正确
有谁能解释下这个正则表达式的意思吗?public bool IsEMail(string str)
{
Regex rx = new Regex(@"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*");
return rx.IsMatch(str);
}
解决方案 »
- 求.net下ajax操作Application对象(Application内的数据为自定义类对象)的方法
- 关于IIS6.0 应用程序池的几个问题
- 在Datagrid中创建了??????????????
- 控件的修饰符设置的奇怪问题
- 高手们快来帮我看看这是为什么啊?!!急!一定要来看看啊
- 在UPDATE前如何批量修改DATASET内数据?
- 怎样设轩datalist里的模板列?
- 提交的问题(在线等)
- 在asp.net页面上,怎样做到当点击一个按钮时,显示“正在运算”,当运算结束后,显示“运算完成”,请朋友们帮忙!!
- 如何验证一个Email地址的有效性
- 为什么取不到 select 的值(vb.net)
- 菜鸟请教视图状态问题
网上原来的不是这个样子的吧,你自己改过了是吧//暂时没有测试环境,试下吧
public bool IsEMail(string str)
{
Regex rx = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*$");
return rx.IsMatch(str);
}另外这个正则只是个通用规则,不一定适合你的需求,正则这东东最好按自己的需求来写,没什么通用的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="GridviewGenColum.WebForm5" %><!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" onblur="check(this)"/>
<script type="text/javascript">
function checkEmail(str)
{
var regex = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if(str.match(regex) == null)
return false
else
return true;
}
function check(obj)
{
if(checkEmail(obj.value))
alert("郵箱地址正確");
else
alert("請輸入正確的郵箱地址");
}
</script>
</div>
</form>
</body>
</html>