什么是C#中的Windows域用户名的正则表达式? [英] What is the Regex for Windows Domain Username in C#?

查看:817
本文介绍了什么是C#中的Windows域用户名的正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是只接受文本,数字和反斜杠的正则表达式。它不应该接受空格,并且应该只以文本开头。例如domain\username。感谢提前...

What is the regular expression to accept only text, number and backslash. It should not accept space and should start with text only. For example domain\username. Thanks in advance...

推荐答案

这是一个正则表达式domain \\\
ame,限制'domain'一个炭和结束与一个炭。您可以轻松地为您的愿望管理正则表达式。

this is a regex for domain\name with the restriction that 'domain' should start with a char and end with a char. You can easily maniplate the regex for your desire

/^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z]\.[a-zA-Z]{2,}$/

域 - 开始:

    [a-zA-Z] Text

域 - 文本:

   1-61 times of [a-zA-Z0-9-] Text, Numbers, '-'

网域 - 结束:

   1 time [a-zA-Z] = Text

反斜杠:

   1 time [\]

用户 - 文本:

   2-infinity times [a-zA-Z] = Text

编辑:as bgh在评论中指出您可以包含更多有效的字符

as bgh pointed out in the comment you could include more valid characters

/^[a-zA-Z][a-zA-Z0-9‌​\-\.]{0,61}[a-zA-Z]\\\w‌​[\w\.\- ]*$/

这篇关于什么是C#中的Windows域用户名的正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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