使用环视:
^(?!.*[-'‘’ ]{2})(?![-'‘’ ])(?!.*[-'‘’ ]$)[a-zA-Zåçêëèïîìæôöòûùÿáíóúñ '‘’-]+$
见proof。
说明
--------------------------------------------------------------------------------
^ 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
string