我需要帮助构建正则表达式以验证 Javascript 中的字符串格式,
字符串的总长度应介于 3 到 30 个字符之间。第一个字符必须是严格的字母表。后续字符可以是字母表或点或空格。请帮忙。
最佳答案
以下将对您有用。
var re = /^[a-z][a-z. ]{2,29}$/i
正则表达式:
^ # the beginning of the string
[a-z] # any character of: 'a' to 'z'
[a-z. ]{2,29} # any character of: 'a' to 'z', '.', ' ' (between 2 and 29 times)
$ # before an optional \n, and the end of the string
关于javascript - 在 JS 中使用正则表达式进行字符串验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23966308/