gpt4 book ai didi

匹配下级登录名的正则表达式

转载 作者:可可西里 更新时间:2023-11-01 11:18:52 26 4
gpt4 key购买 nike

我想验证用户输入的下层登录名。有什么想法吗?

这是给定的下级登录名格式:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa380525%28v=vs.85%29.aspx

最佳答案

作为MSDN声明,它由NetBIOS 域名\用户帐户名组成。

NetBIOS domain name有一些限制:

NetBIOS domain names can contain all alphanumeric characters except for the extended characters that are listed in the "Disallowed characters" section. Names can contain a period, but names cannot start with a period.

Minimum name length 1 character. Maximum name length 15 characters.

可以用[a-zA-Z0-9][a-zA-Z0-9.]{0,14}表示

User account name也有一些限制:

Logon names can be up to 104 characters. However, it isn't practical to use logon names that are longer than 64 characters.

Logon names can't contain certain characters. Invalid characters are " / \ [ ] : ; | = , + * ? < >

Logon names can contain all other special characters, including spaces, periods, dashes, and underscores. But it's generally not a good idea to use spaces in account names.

可以用 [^"/\\\[\]:;|=,+*?<>]{1,104} 表示

因为它没有说明最小长度,所以我在那里放了 1 个字符。我没遇到过允许空用户帐号的系统。

最后,它一起创建了 [a-zA-Z0-9][a-zA-Z0-9.]{0,14}\\[^"/\\\[\]:;|=,+*?<>]{1,104}匹配 NetBIOS 域名\用户帐户名


不过这些都是技术上的限制,在现实生活中很少用到。例如.在 NetBIOS 域名以及 space 中非常不鼓励在用户帐户名称中。用户帐户的常见最大长度是 64 而不是 104,在 2000 等较旧的 Windows 上它甚至是 20。

更现实的可能是[a-zA-Z0-9]{1,15}\\[a-zA-Z0-9._-]{1,64} ,但这取决于您。

关于匹配下级登录名的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21856786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com