求几个正则表达式 一、只允许输入汉字、大小写字母、数字、减号二、只允许输入大小写字母、数字、减号 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ^.[A-Za-z0-9]+$ 在网上找的 如果 输入 %786sdf IsMatch也返回TRUE 一、^[a-zA-Z0-9\-\u4E00-\u9FA5\uF900-\uFA2D]+$二、^[a-zA-Z0-9\-]+$ \uF900-\uFA2D这是什么的范围阿?? 只要找到是否有 非数字,非字母,非减号,非中文的字符存在就可以了。取反一下输出,我在C# winform测试using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Text.RegularExpressions;namespace test.CSDN.ChineseOnly{ public partial class ChineseOnly : Form { public ChineseOnly() { InitializeComponent(); } private void button_test_Click(object sender ,EventArgs e) { bool result = CheckInput(this.textBox1.Text.Trim()); MessageBox.Show(result.ToString()); } private bool CheckInput(string p) { return ! IsRegEx(@"[^- 0-9 A-Z a-z \u4e00-\u9fa5]" ,p); } private bool IsRegEx(string regExValue ,string itemValue) { try { Regex regex = new System.Text.RegularExpressions.Regex(regExValue); if (regex.IsMatch(itemValue)) return true; else return false; } catch (Exception) { return false; } finally { } } }} C#中 DataGridView的单击表头的一个错误??? 关于用户控件的问题 问个简单的调试问题。。 c#如何获取路由器弹出来的账号密码文本框 请问如何实现这样的信息提示框? 数据库与dataGridView问题,快来救我!!! 两台机器之间的复制文件的问题... datagrid中加入checkbox取得checkbox的值 屏蔽一些列 如何在panel控件中动态创建checkbox呢?为什么在没有PANEL的窗体中就能创建呢?高手请进~ 在下画饼图遇到一个问题,高分相送,欢迎大家来讨论! ★★★★★ 小白请教:一段关于委托的简单代码 ★★★★★ FileCopy的问题
二、^[a-zA-Z0-9\-]+$
这是什么的范围阿??
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;namespace test.CSDN.ChineseOnly
{
public partial class ChineseOnly : Form
{
public ChineseOnly()
{
InitializeComponent();
} private void button_test_Click(object sender ,EventArgs e)
{
bool result = CheckInput(this.textBox1.Text.Trim());
MessageBox.Show(result.ToString());
} private bool CheckInput(string p)
{
return ! IsRegEx(@"[^- 0-9 A-Z a-z \u4e00-\u9fa5]" ,p);
} private bool IsRegEx(string regExValue ,string itemValue)
{
try
{
Regex regex = new System.Text.RegularExpressions.Regex(regExValue);
if (regex.IsMatch(itemValue)) return true;
else return false;
}
catch (Exception)
{
return false;
}
finally
{
}
}
}
}