Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JS中正则表达式的字符串验证_Javascript_Regex_Validation - Fatal编程技术网

Javascript JS中正则表达式的字符串验证

Javascript JS中正则表达式的字符串验证,javascript,regex,validation,Javascript,Regex,Validation,我需要一个帮助来构建一个正则表达式来验证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

我需要一个帮助来构建一个正则表达式来验证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

以下内容适用于您

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

\s
将匹配制表符和换行符。应该使用显式空间。简单高效+1:)
发生了什么事?
刚把我的信发给聊天室里的Regex Santa,可能会在那里看到你?去喂邻居的猫一段时间。一定要喜欢比赛条件:-)
\s
将匹配标签和换行符。应该使用显式空间。简单高效+1:)
发生了什么事?
刚把我的信发给聊天室里的Regex Santa,可能会在那里看到你?去喂邻居的猫一段时间。一定要热爱比赛条件:-)