您好,我的 Name 正则表达式有问题
以下是我的要求:
以字符 - az - 一个或多个开头
然后它可以有空格或连字符
它必须以字符 az 结尾
这是我写的,但它不起作用
[a-zA-Z]+$/-*/s*";
试试下面的表达式:
^ # start-of-string
[a-z]+ # one ore more characters at the start
[ -] # match a space or a hyphen
[a-z] # match a character at the end
$ # match the end-of-string
这可能有效 -
^(?i)[a-z]+[\ -].*[a-z]$
^ # Beginning of string
(?i) # Case insensitive modifier group
[a-z]+ # 1 or more a-z or A-Z
[\ -] # Space or -
.* # 0 or more any character
[a-z] # 1 a-z or A-Z
$ # End of string