我需要这个要求的详细验证:
Le'brahmBen-John不能接受Le' brahm、Ben -John或Ben- John
我目前使用此regex,但不能完全填充数字4的要求和数字3的部分。
^[a-zA-Z åçêëèïîìæôöòûùÿáíóúñ]*$如果我像这样加催眠药
^[a-zA-Z -'åçêëèïîìæôöòûùÿáíóúñ]*$正则表达式变成错误,它接受数字字符(不应该是)
发布于 2020-12-12 17:22:56
您可以试试这个正则表达式:
^[a-zA-Zåçêëèïîìæôöòûùÿáíóúñ]+(?:[-' ][a-zA-Zåçêëèïîìæôöòûùÿáíóúñ]+)*$RegEx详细信息:
[a-zA-Zåçêëèïîìæôöòûùÿáíóúñ]+:匹配[...]中给定字母的1+(?:[-' ][a-zA-Zåçêëèïîìæôöòûùÿáíóúñ]+)*:匹配由-、'或空格分隔的同一组字符中的0或多个。发布于 2020-12-12 21:10:04
使用观景台:
^(?!.*[-'‘’ ]{2})(?![-'‘’ ])(?!.*[-'‘’ ]$)[a-zA-Zåçêëèïîìæôöòûùÿáíóúñ '‘’-]+$见证明。
解释
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
.* any character except \n (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
[-‘’' ]{2} any character of: '-', ''', ' ', '‘', '’' (2
times)
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
[-'‘’ ] any character of: '-', ''', ' ', '‘', '’'
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
.* any character except \n (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
[-'‘’ ] any character of: '-', ''', ' ', '‘', '’'
--------------------------------------------------------------------------------
$ before an optional \n, and the end of
the string
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
[a-zA- any character of: 'a' to 'z', 'A' to 'Z',
Zåçêëèïîìæôöòûùÿáíóú 'å', 'ç', 'ê', 'ë', 'è', 'ï', 'î', 'ì',
ñ '‘’-]+ 'æ', 'ô', 'ö', 'ò', 'û', 'ù', 'ÿ', 'á',
'í', 'ó', 'ú', 'ñ', ' ', ''', '-', '‘', '’' (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
stringhttps://stackoverflow.com/questions/65267680
复制相似问题