如何验证用户名,该用户名应以字符开头,然后是下划线,然后是字符,但没有特殊字符 [英] How to validate UserName that should start with characters followed by underscore and then followed by characters but no special chacracters

查看:110
本文介绍了如何验证用户名,该用户名应以字符开头,然后是下划线,然后是字符,但没有特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好... !!
如何验证用户名,该用户名应以字符开头,然后是下划线,然后是字符,但不能包含特殊字符..

任何建议

谢谢...

Hello Everyone...!!
How to validate User Name that should start with characters followed by underscore and then followed by characters but no special characters..

Any Suggestions

Thanks...

推荐答案

试试看.这对你有帮助.

Hi, Try This. It will help u.

using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs ex)
        {

            string Content1 = "a_b";
            string Content2 = "a_@";
            string pattern = @"[A-Za-z]_[A-Za-z]";


            Regex.IsMatch(Content1, pattern); // will return true
            Regex.IsMatch(Content2, pattern); // will return false


        }
    }


}


这篇关于如何验证用户名,该用户名应以字符开头,然后是下划线,然后是字符,但没有特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆