C# Regex.IsMatch (正则表达式验证:数字、小数点、邮件、计算表达式)
public bool isInt(string str)
{
//^([+-]?)表示加减号只能出现在字符串开头且只有一位
///d*表示后面可以有多个或一个十进制数
//$表示字符串结尾
return Regex.IsMatch(str, @"^([+-]?)/d*$");//返回只能以正负号开头的整数
}
public bool isUnInt(string str)
{
//^([+-]?)表示加减号只能出现在字符串开头且只有一位
///d*表示后面可以有多个或一个十进制数
//$表示字符串结尾
return Regex.IsMatch(str, @"^/d*$");//返回整数
}
public bool isEmail(string str)
{
//邮件格式是字符串@字符串.字符串(最后的字符串限制为1到3位)
return Regex.IsMatch(str, @"^([/w]*)([@]?)([/w]*)([.]?)([/w]{1,3})$");
}
public bool checkFloat(string svalue)
{
//检查值是否为浮点数字,5位小数
return Regex.IsMatch(svalue, @"^(/d*)([.]{0,1})(/d{0,5})$");
}
public bool isNumeric(string str)
{
//判断是否是数值,有小数点
return Regex.IsMatch(str, @"^([+-]?)/d*[.]?/d*$");
}
public bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn, @"^([/w-/.]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([/w-]+/.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(/]?)$");
} public static bool checkString(string svalue)
{
if (Regex.IsMatch(svalue, @"^([0-9]{1,})(.*)([0-9]{1,})$"))
{
//如果表达式头尾是数字
//在检查是否匹配运算符是不是加减乘除,如果不是返回真
if (Regex.IsMatch(svalue, @"(([0-9]{1,})([/+/-/*//]{2,})([0-9]{1,}))|(([0-9]{1,})([^/+/-/*//]{1,})([0-9]{1,}))"))
{
//表示表达式不合法
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
C# Regex.IsMatch (正则表达式验证:数字、小数点、邮件、计算表达式)的更多相关文章
- JS正则表达式验证数字
<script type="text/javascript"> function validate(){ var reg = new RegExp("^[0- ...
- JS正则表达式验证数字(很全)
1.<script type="text/javascript"> 2. function validate(){ 3. var reg = new ...
- JS正则表达式验证数字非常全
<script type="text/javascript"> function validate(){ var reg = new RegExp("^[0- ...
- JavaScript 【正则表达式验证数字代码】
可以看到 Ajax 请求多了个 x-requested-with ,可以利用它,request.getHeader("x-requested-with"); 为 null,则为传统 ...
- 正则表达式验证数字、汉字、电话号码,email,整数,浮点数
验证数字的正则表达式集 验证数字:^[0-9]*$验证n位的数字:^\d{n}$验证至少n位数字:^\d{n,}$验证m-n位的数字:^\d{m,n}$验证零和非零开头的数字:^(0|[1-9][0- ...
- 黄聪:JS正则表达式验证数字
<script type="text/JavaScript"> function validate(){ var reg = new RegExp( ...
- js 正则表达式 验证数字或字母
let reg= /^(^[0-9]*$)|(^[A-Za-z]+$)/ /*reg= /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]$/*/ if(!reg.test( ...
- C# 验证数字的正则表达式集
验证数字的正则表达式集 博客分类: 正则 正则表达式 验证数字的正则表达式集 验证数字:^[0-9]*$ 验证n位的数字:^\d{n}$ 验证至少n位数字:^\d{n,}$ 验证m-n位的数字:^\d ...
- C# 正则表达式 验证:数字、带小数点数字、电话和手机
一.带小数点数字 public static bool IsNumber(string input) { string pattern = "^-?\\d+$|^(-?\\d+)(\\.\\ ...
随机推荐
- 如何用JS判断网页中某个id的网页元素是否存在
<meta http-equiv="content-type" content="text/html;charset=utf-8" /> <m ...
- React Native 组件之Image
Image组件类似于iOS中UIImage控件,该组件可以通过多种方式加载图片资源. 使用方式,加载方式有如下几种: /** * Sample React Native App * https://g ...
- post&get请求总结
1.将get获取的数据,UrlDecode后返回 public static string SendGet(string url) { HttpWebRequest httpWebRequest = ...
- 浅谈__declspec(dllexport)和__declspec(dllimport)
__declspec(dllimport)和__declspec(dllexport)经常是成对的,在动态链接库中__declspec(dllexport)导出dll中的成员,__declspec(d ...
- Linux关机命令
1.halt :关机 init 0 : 关机 shutdown -h now (立刻关机) -h 指的是 halt 2.reboot 重启 init 0 重启 shutdown -r no ...
- 【ES5】hideProperty
function hideProperty(host, name, value) { Object.defineProperty(host, name, { value: value, writabl ...
- 【Sublime Text 3】
- linux性能监控基础命令
压力测试监控下系统性能方法之一 #top 该命令监控的是进程的信息 看图逐行意义 top:执行命令的之间 up:已经执行了277天 2users:目前有两个使用者,使用#who可以查看具体的使用者详情 ...
- MapBox TileMill
TileMill 学习网站: Walkthrough: Creating tiles with Mapnik using TileMill TileMill 快速入门 Cartography With ...
- 如何禁用ListView中的选中效果
有的时候,我们希望ListView没有选中效果. 导致选中效果出现可能有两方面的原因: 1.每一行View自身可能有选中效果,可以将它的背景设置为透明 2.ListView有一个listSelecto ...