普通防爆pression用户名和密码? [英] Regular Expression for username and password?

查看:199
本文介绍了普通防爆pression用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用name字段经常EX pression在asp.net应用程序。

I am trying to use a regular expression for name field in the asp.net application.

条件:名称应该是最少6个字符

Conditions:name should be minimum 6 characters ?

我尝试以下

"^(?=.*\d).{6}$"

我为全新的regex.Can任何一个建议我什么必须是这样的条件正则表达式?

I m completely new to the regex.Can any one suggest me what must be the regex for such condition ?

推荐答案

看着前pression图书馆和选择的用户名和/或密码正则表达式为你。您还可以测试在网上正则表达式测试您的正则如 RegexPlanet。

Look at Expression library and choose user name and/or password regex for you. You can also test your regex in online regex testers like RegexPlanet.

我的正则表达式的建议是:

My regex suggestions are:

 ^[a-zA-Z][a-zA-Z0-9._\-]{5,}$

这正则表达式接受以最小的6个字符,以字母开头,只含有字母,数字和用户名,。, - ,_字符。

This regex accepts user names with minimum 6 characters, starting with a letter and containing only letters, numbers and ".","-","_" characters.

下一个:

 ^[a-zA-Z0-9._\\-]{6,}$

以上相似,但接受。, - ,_和0-9是第一个字符了。

Similar to above, but accepts ".", "-", "_" and 0-9 to be first characters too.

如果您想验证只有字符串的长度(至少6个字符),低于这个简单的regex将是不够的:

If you want to validate only string length (minimum 6 characters), this simple regex below will be enough:

 ^.{6,}$

这篇关于普通防爆pression用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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