What is the regex to match an alphanumeric 6 character string?

被刻印的时光 ゝ 提交于 2019-12-08 14:44:11

问题


I need regex for asp.net application to match an alphanumeric string at least 6 characters long.


回答1:


I’m not familiar with ASP.NET. But the regular expression should look like this:

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

^ and $ denote the begin and end of the string respectively; [a-zA-Z0-9] describes one single alphanumeric character and {6,} allows six or more repetitions.




回答2:


I would use this:

^[\p{L}\p{N}]{6,}$

This matches Unicode letters (\p{L}) and numbers (\p{N}), so it's not limited to common letters the Latin alphabet.




回答3:


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

(Depending on the Regex implementation)

Note, that \w also matches _!



来源:https://stackoverflow.com/questions/3658145/what-is-the-regex-to-match-an-alphanumeric-6-character-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!